SQL Training
Build a small shop reporting project to bring the lessons together. The goal is a set of trustworthy queries with clear requirements and repeatable checks, not a page full of unexplained SQL snippets.
Understand the idea
Create four outputs: available products, paid sales by customer, daily paid revenue, and order-total mismatches. Record the grain and units of every output. Add a customer with no orders and two orders on one date to test edge cases. The worked query below is the daily revenue report; keep its paid-status rule explicit in your project notes.
Where to try it
Run this example in the SQL playground. The lesson link loads the shop tables and sample rows before this query. Select Run when you are ready. Every run starts fresh, so your changes do not affect the website or a previous run.
SQLite sample data · MySQL / MariaDB sample data · See the sample tables
Your task
Complete the four reports, document one edge case for each, and review a query plan after adding realistic amounts of test data.
Show the worked solution
SELECT ordered_at AS sales_date, COUNT(*) AS paid_orders,
SUM(total_cents) AS paid_cents
FROM orders WHERE status = 'paid'
GROUP BY ordered_at
ORDER BY ordered_at;
Check your result
The sample gives 2300 cents on 2026-01-05 and 1350 on 2026-01-06, one paid order on each date. A date with no paid orders is absent; a calendar join would be needed to show zero days.