Learn SQL
Work top to bottom, or jump to a track. Each lesson pairs a short explanation with exercises you run right here in the browser, with hints and solutions when you get stuck. It is free with no account: your progress is saved in this browser.
Foundations
Start here: the essentials, in order. 0/24Enter here if you have never written a query.
01
0/6 Welcome to the Shed
What SQL is · the workbench · SELECT · WHERE · ORDER BY
Lessons
Welcome to the Shed
What SQL is · the workbench · SELECT · WHERE · ORDER BY
02
0/8 Data Types Before Deep Querying
Numbers · strings · dates · booleans · nulls · precision · unknown
Lessons
Data Types Before Deep Querying
Numbers · strings · dates · booleans · nulls · precision · unknown
03
0/5 Filtering in Depth
DISTINCT · AND/OR · IN · BETWEEN · LIKE
Lessons
Filtering in Depth
DISTINCT · AND/OR · IN · BETWEEN · LIKE
04
0/5 Aggregations and Grouping
COUNT · SUM · AVG · MIN · MAX · GROUP BY · HAVING · bool_and · FILTER
Lessons
Aggregations and Grouping
COUNT · SUM · AVG · MIN · MAX · GROUP BY · HAVING · bool_and · FILTER
Joins & Logic
Combine tables and shape your output. 0/16Enter here if SELECT, WHERE, and GROUP BY feel comfortable and joins do not.
05
0/6 Joins
INNER · LEFT · FULL · CROSS · self-joins · multiplication
Lessons
Joins
INNER · LEFT · FULL · CROSS · self-joins · multiplication
06
0/4 CASE Logic and Derived Columns
Calculated columns · CASE WHEN · COALESCE
Lessons
CASE Logic and Derived Columns
Calculated columns · CASE WHEN · COALESCE
07
0/6 Dates, Strings, and Nulls in Practice
Date math · string cleanup · safe null handling · regex · fuzzy matching
Lessons
Dates, Strings, and Nulls in Practice
Date math · string cleanup · safe null handling · regex · fuzzy matching
Change & Debug
Edit data safely, then fix what breaks. 0/14Enter here before you run an UPDATE on anything that matters.
08
0/10 Changing Data and Tables
INSERT · UPDATE · DELETE · transactions · CREATE · constraints · ALTER
Lessons
Changing Data and Tables
INSERT · UPDATE · DELETE · transactions · CREATE · constraints · ALTER
09
0/4 Query Debugging and Common Mistakes
Reading errors · small steps · wrong answers without errors · formatting
Lessons
Query Debugging and Common Mistakes
Reading errors · small steps · wrong answers without errors · formatting
Analytics & Applied Practice
Subqueries, then real reporting questions on fresh datasets. 0/32Enter here if you write SQL at work and want reports: rates, cohorts, windows, CTEs.
10
0/9 Subqueries and EXISTS
Nested SELECTs · IN · EXISTS · NOT IN traps · ANY and ALL · latest row per group
Lessons
Subqueries and EXISTS
Nested SELECTs · IN · EXISTS · NOT IN traps · ANY and ALL · latest row per group
11
0/7 Practical Analytics Patterns
Top-N · rates · cohorts · windows · CTEs · QUALIFY · recursive CTEs
Lessons
Practical Analytics Patterns
Top-N · rates · cohorts · windows · CTEs · QUALIFY · recursive CTEs
12
0/6 Applied Practice: Movie Rentals
Reapply joins · aggregates · dates · nulls on a fresh dataset
Lessons
Applied Practice: Movie Rentals
Reapply joins · aggregates · dates · nulls on a fresh dataset
13
0/6 Applied Practice: Website Analytics
Funnels · attribution · conversion rates on a marketing dataset
Lessons
Applied Practice: Website Analytics
Funnels · attribution · conversion rates on a marketing dataset
14
0/4 Applied Practice: Store Operations
Revenue · inventory · customer value · supplier margin
Lessons
Applied Practice: Store Operations
Revenue · inventory · customer value · supplier margin
Advanced
Sets, pivots, missions, modeling, windows, statistics, time series, and nested data. 0/41Enter here if you know SQL from PostgreSQL or MySQL and want the harder half, plus what DuckDB does differently.
15
0/4 Set Operations
UNION ALL · UNION · INTERSECT · EXCEPT
Lessons
Set Operations
UNION ALL · UNION · INTERSECT · EXCEPT
16
0/6 Summary Reports and Pivots
Conditional aggregation · ROLLUP · STRING_AGG · CASE buckets · GROUPING SETS · PIVOT
Lessons
Summary Reports and Pivots
Conditional aggregation · ROLLUP · STRING_AGG · CASE buckets · GROUPING SETS · PIVOT
17
0/8 Guided Playground Missions
Dataset scouting · revenue audits · scorecards · conversion reports
Lessons
Guided Playground Missions
Dataset scouting · revenue audits · scorecards · conversion reports
18
0/5 Modeling and Data Quality
Profiling · quality checks · semantic views · staging · rerunnable scripts
Lessons
Modeling and Data Quality
Profiling · quality checks · semantic views · staging · rerunnable scripts
19
0/7 Window Functions in Depth
Ranking ties · LAG and LEAD · running totals · frames · share of total · top N per group · landing pages
Lessons
Window Functions in Depth
Ranking ties · LAG and LEAD · running totals · frames · share of total · top N per group · landing pages
20
0/4 Statistics and Distributions
Medians and percentiles · standard deviation · mode · histograms
Lessons
Statistics and Distributions
Medians and percentiles · standard deviation · mode · histograms
21
0/3 Time Series in SQL
Period over period · date spines · rolling calendar windows
Lessons
Time Series in SQL
Period over period · date spines · rolling calendar windows
22
0/4 Lists, Structs, and JSON
list() · unnest · structs · JSON paths · -> and ->>
Lessons
Lists, Structs, and JSON
list() · unnest · structs · JSON paths · -> and ->>
All 22 chapters are live, grouped into 5 tracks: Foundations, Joins & Logic, Change & Debug, Analytics & Applied Practice, and Advanced. Work through a track in order, or jump straight to the one you need.
What this workshop is, and is not
SQLShed teaches the SQL you write to answer questions: selecting, joining, grouping, windows, building tables, and changing data safely, in DuckDB's dialect with the portable form shown alongside. It doesn't cover running a database: indexes, query plans, permissions, or protecting an application from SQL injection. Those depend on the engine you deploy, though the reference explains indexes and query plans.
When you finish, take one of the practice datasets into PostgreSQL or SQLite and rebuild a report there.