sqlstreak

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.

Download .sql (PostgreSQL + SQLite) SQLite .db CSV (zip) Query it online5 tables · 78 rows · CC BY 4.0

Tables and columns

A small pizza shop with big data: customers, a menu and a month of orders.

Rocket Pizza: tables, keys and how they connectstaff🔑 idnamerolecitymanager_idhired_oncustomers🔑 idnamecityjoined_onorders🔑 idcustomer_idordered_onstatusorder_itemsorder_iditem_idquantitymenu_items🔑 idnamecategorypricevegetarian
🔑 primary key · blue columns point at another table (foreign keys); the arrows show where.

customers

10 rows

People who have ordered at least once — or signed up and never did.

  • idinteger
  • nametext
  • citytext
  • joined_ondate

menu_items

11 rows

Everything you can order.

  • idinteger
  • nametext
  • categorytextpizza, side, drink or dessert
  • pricenumericdollars
  • vegetarianboolean

orders

17 rows

One row per order.

  • idinteger
  • customer_idinteger→ customers.id
  • ordered_ondate
  • statustextdelivered, preparing or cancelled

order_items

32 rows

What was in each order.

  • order_idinteger→ orders.id
  • item_idinteger→ menu_items.id
  • quantityinteger

staff

8 rows

Everyone 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

idnamecityjoined_on
1Maya OrtizAustin2025-02-11
2Jonah ReedDenver2025-03-04
3Priya NairAustin2025-03-19
4Tomás HerreraBoston2025-05-02
5Ellie ParkDenver2025-06-15

menu_items

idnamecategorypricevegetarian
1Margheritapizza111
2Pepperoni Rocketpizza13.50
3Four Cheese Orbitpizza141
4BBQ Meteorpizza15.50
5Veggie Nebulapizza131

orders

idcustomer_idordered_onstatus
112026-03-01delivered
222026-03-01delivered
312026-03-03delivered
432026-03-04cancelled
542026-03-05delivered

order_items

order_iditem_idquantity
112
192
221
271
331

staff

idnamerolecitymanager_idhired_on
1Rosa VegaownerAustinNULL2024-01-10
2Omar HaddadmanagerAustin12024-03-01
3Lia MoreaumanagerDenver12024-06-15
4Ben CarterchefAustin22024-04-20
5Yuki TanakadriverAustin22025-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

categoryrevenue
pizza320.5
side61
drink24.5
dessert19.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

categorynameprice
dessertTiramisu6.5
drinkLemon Soda3
pizzaBBQ Meteor15.5
sideWings8.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

employeemanager
Rosa VegaNULL
Omar HaddadRosa Vega
Lia MoreauRosa Vega
Ben CarterOmar Haddad
Yuki TanakaOmar Haddad
Ivan PetrovLia Moreau
Zara AliLia Moreau
Noah KimLia 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

statusorders
delivered13
cancelled2
preparing2
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_idtotal
1059
642
1340.5
1232.5
431
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

citycustomers
Austin3
Denver3
Boston2
Chicago2
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

nameorders
Maya Ortiz4
Jonah Reed3
Ellie Park2
Marcus Bell2
Sam Okafor2
Tomás Herrera2
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_onorders
2026-03-012
2026-03-052
2026-03-222
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

cityrolepeople
Austinchef1
Austindriver1
Austinmanager1
Austinowner1
Denverchef1
Denverdriver1
Denvermanager1
Seattledriver1

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.

License

Free to use in courses, tutorials, blog posts and interviews under CC BY 4.0. Please credit it with a link: Data: sqlstreak.com/datasets/pizza

Teaching with it? Tell me and I'll help.

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 lesson

Guides that use it

Practice on it

More sample databases