Rocket Pizza: a free sample database for SQL practice
Rocket Pizza is a small pizza shop with exactly the tables you need to practise real business questions: customers, a menu, a month of orders with line items, and staff with managers. It's small enough to understand at a glance and rich enough for joins, aggregates, window functions and self joins.
Tables and columns
A small pizza shop with big data: customers, a menu and a month of orders.
customers
10 rowsPeople who have ordered at least once — or signed up and never did.
- idinteger
- nametext
- citytext
- joined_ondate
menu_items
11 rowsEverything you can order.
- idinteger
- nametext
- categorytextpizza, side, drink or dessert
- pricenumericdollars
- vegetarianboolean
orders
17 rowsOne row per order.
- idinteger
- customer_idinteger→ customers.id
- ordered_ondate
- statustextdelivered, preparing or cancelled
order_items
32 rowsWhat was in each order.
- order_idinteger→ orders.id
- item_idinteger→ menu_items.id
- quantityinteger
staff
8 rowsEveryone who works at Rocket Pizza.
- idinteger
- nametext
- roletextowner, manager, chef or driver
- citytext
- manager_idinteger→ staff.id
- hired_ondate
What the data looks like
The first five rows of each table.
customers
| id | name | city | joined_on |
|---|---|---|---|
| 1 | Maya Ortiz | Austin | 2025-02-11 |
| 2 | Jonah Reed | Denver | 2025-03-04 |
| 3 | Priya Nair | Austin | 2025-03-19 |
| 4 | Tomás Herrera | Boston | 2025-05-02 |
| 5 | Ellie Park | Denver | 2025-06-15 |
menu_items
| id | name | category | price | vegetarian |
|---|---|---|---|---|
| 1 | Margherita | pizza | 11 | 1 |
| 2 | Pepperoni Rocket | pizza | 13.5 | 0 |
| 3 | Four Cheese Orbit | pizza | 14 | 1 |
| 4 | BBQ Meteor | pizza | 15.5 | 0 |
| 5 | Veggie Nebula | pizza | 13 | 1 |
orders
| id | customer_id | ordered_on | status |
|---|---|---|---|
| 1 | 1 | 2026-03-01 | delivered |
| 2 | 2 | 2026-03-01 | delivered |
| 3 | 1 | 2026-03-03 | delivered |
| 4 | 3 | 2026-03-04 | cancelled |
| 5 | 4 | 2026-03-05 | delivered |
order_items
| order_id | item_id | quantity |
|---|---|---|
| 1 | 1 | 2 |
| 1 | 9 | 2 |
| 2 | 2 | 1 |
| 2 | 7 | 1 |
| 3 | 3 | 1 |
staff
| id | name | role | city | manager_id | hired_on |
|---|---|---|---|---|---|
| 1 | Rosa Vega | owner | Austin | NULL | 2024-01-10 |
| 2 | Omar Haddad | manager | Austin | 1 | 2024-03-01 |
| 3 | Lia Moreau | manager | Denver | 1 | 2024-06-15 |
| 4 | Ben Carter | chef | Austin | 2 | 2024-04-20 |
| 5 | Yuki Tanaka | driver | Austin | 2 | 2025-02-01 |
SQL practice questions for this database
Good for: JOINs across 3–4 tables · GROUP BY and revenue reports · Window functions and rankings · Self joins (staff and managers) · LEFT JOIN and “never ordered” questions. Try them yourself first, then compare.
Revenue per menu categoryShow a solution
SELECT m.category, SUM(oi.quantity * m.price) AS revenue FROM order_items oi JOIN menu_items m ON m.id = oi.item_id GROUP BY m.category ORDER BY revenue DESC;
Result (PostgreSQL and SQLite, identical): 4 rows
| category | revenue |
|---|---|
| pizza | 320.5 |
| side | 61 |
| drink | 24.5 |
| dessert | 19.5 |
Customers who have never orderedShow a solution
SELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL;
Result (PostgreSQL): 2 rows
| name |
|---|
| Diego Santos |
| Nora Lindqvist |
The most expensive item in each categoryShow a solution
SELECT category, name, price FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY category ORDER BY price DESC) AS rn FROM menu_items) t WHERE rn = 1;
Result (PostgreSQL and SQLite, identical): 4 rows
| category | name | price |
|---|---|---|
| dessert | Tiramisu | 6.5 |
| drink | Lemon Soda | 3 |
| pizza | BBQ Meteor | 15.5 |
| side | Wings | 8.5 |
Each employee and their managerShow a solution
SELECT e.name AS employee, m.name AS manager FROM staff e LEFT JOIN staff m ON m.id = e.manager_id;
Result (PostgreSQL and SQLite, identical): 8 rows
| employee | manager |
|---|---|
| Rosa Vega | NULL |
| Omar Haddad | Rosa Vega |
| Lia Moreau | Rosa Vega |
| Ben Carter | Omar Haddad |
| Yuki Tanaka | Omar Haddad |
| Ivan Petrov | Lia Moreau |
| Zara Ali | Lia Moreau |
| Noah Kim | Lia Moreau |
Orders per statusShow a solution
SELECT status, COUNT(*) AS orders FROM orders GROUP BY status ORDER BY orders DESC, status;
Result (PostgreSQL and SQLite, identical): 3 rows
| status | orders |
|---|---|
| delivered | 13 |
| cancelled | 2 |
| preparing | 2 |
Each order's total, biggest firstShow a solution
SELECT oi.order_id, SUM(oi.quantity * m.price) AS total FROM order_items oi JOIN menu_items m ON m.id = oi.item_id GROUP BY oi.order_id ORDER BY total DESC, oi.order_id LIMIT 5;
Result (PostgreSQL and SQLite, identical): 5 rows
| order_id | total |
|---|---|
| 10 | 59 |
| 6 | 42 |
| 13 | 40.5 |
| 12 | 32.5 |
| 4 | 31 |
Customers per cityShow a solution
SELECT city, COUNT(*) AS customers FROM customers GROUP BY city ORDER BY customers DESC, city;
Result (PostgreSQL and SQLite, identical): 4 rows
| city | customers |
|---|---|
| Austin | 3 |
| Denver | 3 |
| Boston | 2 |
| Chicago | 2 |
Customers who ordered more than onceShow a solution
SELECT c.name, COUNT(*) AS orders FROM customers c JOIN orders o ON o.customer_id = c.id GROUP BY c.id, c.name HAVING COUNT(*) > 1 ORDER BY orders DESC, c.name;
Result (PostgreSQL and SQLite, identical): 6 rows
| name | orders |
|---|---|
| Maya Ortiz | 4 |
| Jonah Reed | 3 |
| Ellie Park | 2 |
| Marcus Bell | 2 |
| Sam Okafor | 2 |
| Tomás Herrera | 2 |
The busiest daysShow a solution
SELECT ordered_on, COUNT(*) AS orders FROM orders GROUP BY ordered_on ORDER BY orders DESC, ordered_on LIMIT 3;
Result (PostgreSQL and SQLite, identical): 3 rows
| ordered_on | orders |
|---|---|
| 2026-03-01 | 2 |
| 2026-03-05 | 2 |
| 2026-03-22 | 2 |
Share of the menu that is vegetarianShow a solution
SELECT ROUND(100.0 * SUM(CASE WHEN vegetarian THEN 1 ELSE 0 END) / COUNT(*), 1) AS vegetarian_pct FROM menu_items;
Result (PostgreSQL and SQLite, identical): 1 row
| vegetarian_pct |
|---|
| 63.6 |
Average value of a delivered orderShow a solution
SELECT ROUND(AVG(total), 2) AS avg_order_value
FROM (SELECT o.id, SUM(oi.quantity * m.price) AS total
FROM orders o
JOIN order_items oi ON oi.order_id = o.id
JOIN menu_items m ON m.id = oi.item_id
WHERE o.status = 'delivered'
GROUP BY o.id) t;Result (PostgreSQL and SQLite, identical): 1 row
| avg_order_value |
|---|
| 27.15 |
Staff per city and roleShow a solution
SELECT city, role, COUNT(*) AS people FROM staff GROUP BY city, role ORDER BY city, role;
Result (PostgreSQL and SQLite, identical): 8 rows
| city | role | people |
|---|---|---|
| Austin | chef | 1 |
| Austin | driver | 1 |
| Austin | manager | 1 |
| Austin | owner | 1 |
| Denver | chef | 1 |
| Denver | driver | 1 |
| Denver | manager | 1 |
| Seattle | driver | 1 |
How to load it
SQLite: sqlite3 pizza.db < sqlstreak-pizza-sample-database.sql
PostgreSQL: psql -d yourdb -f sqlstreak-pizza-sample-database.sql
Or skip installing anything and query it in your browser.
Practise on this data every day
sqlstreak's lessons use these tables: five-minute exercises with instant feedback and a streak. No account needed to start.
Start the first lessonGuides that use it
- PostgreSQL vs SQLite: SQL syntax differences
- SQL CASE WHEN
- SQL string functions
- SQL JOINs explained
- SQL CTEs: the WITH clause
- SQL subqueries
- SQL UNION vs UNION ALL, INTERSECT and EXCEPT
- SQL self joins and CROSS JOIN
- SQL recursive CTEs (WITH RECURSIVE)
- SQL GROUP BY and HAVING
- SQL window functions
- SQL window frames, moving averages, NTILE and ROLLUP
- SQL indexes and EXPLAIN
- SQL interview questions: the core patterns