Recipes
Copy-paste patterns for the SQL problems people actually hit at work — each one runnable against a seeded database.
Reference pages tell you what a clause does. These tell you how to solve a problem: the thing you're actually googling at 4pm.
Every recipe runs against the same small SQLite database (customers, orders,
employees, product_sales, monthly_revenue) — edit the query and press
Run.
Top N per group
The single most-asked SQL question — highest-paid employee per department, latest order per customer.
Deduplicate rows
Keep one row per key when a table has accidental duplicates.
Rows missing in another table
Anti-join: customers with no orders, products never sold.
Pivot without PIVOT
Turn rows into columns with conditional aggregation — portable across engines.
Gaps and islands
Find runs of consecutive values, or the holes between them.
Running totals & moving averages
Cumulative sums, rolling windows, and percent-of-total.