Learn SQL by doing
Learn SQL by doing: write real queries against a real database, with instant feedback. Every lesson runs in your browser, on the same small bakery database.
0 of 13 lessons completed
Basics
Free: read, sort and filter a table.
- Your first SELECTRead columns from a table, sort the rows and remove duplicates.Free
- Filter rows with WHEREKeep only the rows that match a condition, including ranges and missing values.Free
- Patterns, lists and top resultsMatch text with LIKE, test against a list with IN, and keep only the first rows with LIMIT.Free
Summaries
Count, sum and average, per group.
Joins
Combine tables by their keys, including the ones that don't match.
- Combine tables with JOINMatch rows from two tables by a shared key, then group the combined rows.Pro
- Keep rows without a match: LEFT JOINAn inner join drops rows without a match. A left join keeps them, which is how you find what is missing.Pro
- Compare rows within one tableJoin a table to itself to compare its rows with each other, without repeating pairs.Pro
- Many-to-many through a middle tableOrders and products are linked through order_items. Joining through that table answers product-level questions.Pro
Changing data
Add, change and remove rows safely.
From Excel
Lookups, SUMIF, pivot tables and dynamic arrays, in SQL.
- From VLOOKUP to JOINIf you know VLOOKUP and XLOOKUP, you already know the idea behind a JOIN.Pro
- SUMIF, COUNTIFS and pivot tables in SQLConditional sums and counts become WHERE plus SUM or COUNT. A pivot table becomes GROUP BY on two columns.Pro
- FILTER, UNIQUE and SORT in SQLDynamic array functions map onto WHERE, DISTINCT and ORDER BY.Pro
Case study
Answer real questions about one month of sales.