ConceptStep · learning platform for computer science

SQL review: supermarket explorers

SQL and databases · Lesson

SQL · Lesson 7 / 8 · SQLite lab

SQL review: supermarket explorers

Guided SQL review on real food data, with hints and no JOINs.

← Back to SQL path

Before you start

Explore real Open Food Facts data in three independent tables, with no JOINs.

Source and license: Open Food Facts — Open Database License (ODbL) 1.0.

Experiment freely: Reset reloads the original food dataset.

The real dataset

Open Food Facts provides real product data. Three independent tables: products, drinks and cereals. Nutritional values are per 100 g or 100 ml when available; NULL means unknown.

SELECT nome, marca, zuccheri FROM prodotti LIMIT 5;

Filter, sort and limit

Use FROM to pick a table, WHERE to filter. For rankings, combine ORDER BY ... DESC and LIMIT. DISTINCT returns unique entries.

SELECT nome, proteine FROM cereali WHERE proteine IS NOT NULL ORDER BY proteine DESC LIMIT 10;

Interpret results

Rankings describe only the sample. Dry powders and ready-to-drink products are not always comparable. Missing data does not mean zero.

SELECT nome, zuccheri FROM bevande WHERE zuccheri BETWEEN 0 AND 5 ORDER BY zuccheri DESC LIMIT 10;

Lab and practice

0 completed · 10 to go

Write a query for each task. Run it here or in DB Browser; check columns, rows and conditions.

Exercise 1

Show name and brand of ten products with a known brand, alphabetically.

Expected row count: 10

Exercise 2

List distinct categories alphabetically.

Expected row count: 43

Exercise 3

Find 15 drinks with 0–5 g sugar per 100 ml, most sugary first.

Expected row count: 15

Exercise 4

Find the ten highest-protein cereals in this sample, excluding missing values.

Expected row count: 10

Exercise 5

Show ten products above 450 kcal per 100 g, highest first.

Expected row count: 10

Exercise 6

Which cereals have missing sugar values?

Expected row count: 8

Exercise 7

Find ten products with Nutri-Score A or B.

Expected row count: 10

Exercise 8

Find the ten lowest-fat products with available values.

Expected row count: 10

Exercise 9

List twenty different cereal brands.

Expected row count: 20

Exercise 10

Find the ten highest-sugar drinks in the sample.

Expected row count: 10

Choose «Check exercise» to verify your result. If you get stuck, use «Help me» for gradual hints without seeing the full solution immediately.

Your competency map

What you need to know for SQL review: supermarket explorers

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

You can start right away. This is a foundation module: it does not require earlier skills from the learning path.
GUIDED LEARNING PATHS

Want to choose the next skill to develop?