Restaurant orders sample database for MySQL
A ready-to-run MySQL script with order lines with menu items, tickets, order type and payment. Tested on MySQL 8.4.13. Updated 19 November 2026.
Restaurant orders database for MySQL
Each row is one line on a ticket at a fictional restaurant in 2024: ticket number, date and time, item, category, quantity, price and line total, dine-in/takeout/delivery and payment method.
This page has it as a MySQL script: one table and 1,000 rows, with column types chosen for MySQL, primary keys. The script drops the table if it exists, creates it and inserts the rows in one transaction, so you can run it again to reset the data. It is the same fictional data, seed 42, as on the restaurant orders dataset page, where it is also available as CSV and Excel.
We loaded this exact file into MySQL 8.4.13 and ran every question below on it; the answers shown are that output. The same questions, written for SQLite, PostgreSQL, MySQL, SQL Server and DuckDB, return the same results on all five.
Load it
mysql client
mysql -u root -p -e "CREATE DATABASE practice"
mysql -u root -p practice < restaurant-orders-mysql.sqlMySQL Workbench
File > Open SQL Script, choose the database with USE practice; then Execute.
Tables and columns
restaurant_orders 1,000 rows
| Column | MySQL type |
|---|---|
| order_line_id | VARCHAR(10) |
| order_id | VARCHAR(10) |
| date | DATE |
| time | VARCHAR(10) |
| item | VARCHAR(20) |
| category | VARCHAR(20) |
| quantity | INT |
| unit_price | DECIMAL(6,2) |
| line_total | DECIMAL(6,2) |
| order_type | VARCHAR(10) |
| payment_method | VARCHAR(10) |
Practice questions
answers from MySQL 8.4.13
What are sales by menu category?
SQL
SELECT category, SUM(quantity) AS items, ROUND(SUM(line_total), 2) AS sales
FROM restaurant_orders
GROUP BY category
ORDER BY sales DESC, category;Result
| category | items | sales |
|---|---|---|
| Pizza | 376.00 | 5,676.00 |
| Burgers | 190.00 | 2,413.00 |
| Sandwiches | 148.00 | 1,841.00 |
| Salads | 120.00 | 1,259.00 |
| Sides | 207.00 | 956.50 |
| Drinks | 237.00 | 702.00 |
| Desserts | 74.00 | 538.50 |
| Soups | 45.00 | 292.50 |
What is the average order value? (group lines into orders first)
SQL
WITH o AS (
SELECT order_id, SUM(line_total) AS order_total
FROM restaurant_orders
GROUP BY order_id
)
SELECT COUNT(*) AS orders, ROUND(AVG(CAST(order_total AS DECIMAL(18,4))), 2) AS avg_order_value
FROM o;The cast to DECIMAL keeps the average exact before rounding.
Result
| orders | avg_order_value |
|---|---|
| 429 | 31.88 |
Which 5 menu items sell the most units?
SQL
SELECT item, SUM(quantity) AS units
FROM restaurant_orders
GROUP BY item
ORDER BY units DESC, item
LIMIT 5;LIMIT n at the end returns the first n rows.
Result
| item | units |
|---|---|
| Pepperoni Pizza | 162.00 |
| Fries | 157.00 |
| Cheeseburger | 133.00 |
| Margherita Pizza | 126.00 |
| Soda | 95.00 |
How do order types compare (dine-in, takeout, delivery)?
SQL
SELECT order_type, COUNT(DISTINCT order_id) AS orders, ROUND(SUM(line_total), 2) AS sales
FROM restaurant_orders
GROUP BY order_type
ORDER BY sales DESC, order_type;Result
| order_type | orders | sales |
|---|---|---|
| Dine-in | 195 | 6,371.50 |
| Takeout | 145 | 4,557.50 |
| Delivery | 89 | 2,749.50 |
What share of sales does each payment method take, in percent?
SQL
SELECT payment_method, ROUND(1.0 * 100 * SUM(line_total) / NULLIF((SELECT SUM(line_total) FROM restaurant_orders), 0), 2) AS share_pct
FROM restaurant_orders
GROUP BY payment_method
ORDER BY share_pct DESC, payment_method;1.0 * a / b gives a decimal result.
Result
| payment_method | share_pct |
|---|---|
| Card | 65.84 |
| App | 23.58 |
| Cash | 10.57 |
Which hour of the day has the most sales?
SQL
SELECT SUBSTRING(time, 1, 2) AS hour, ROUND(SUM(line_total), 2) AS sales
FROM restaurant_orders
GROUP BY SUBSTRING(time, 1, 2)
ORDER BY sales DESC, hour
LIMIT 3;SUBSTRING(text, start, length) cuts out part of a string.
Result
| hour | sales |
|---|---|
| 12 | 2,502.50 |
| 19 | 2,369.00 |
| 18 | 1,928.00 |
MySQL differences used here
- The cast to DECIMAL keeps the average exact before rounding.
- 1.0 * a / b gives a decimal result.
- SUBSTRING(text, start, length) cuts out part of a string.
- LIMIT n at the end returns the first n rows.