Most cheat sheets list syntax. Yours forgets it by next Tuesday. This one links every clause to a real challenge — so you don't just read SQL, you run it. SELECT through window functions, all in one page.
Print-friendly · Bookmark the section anchors · Cmd+F to search
SQL is written in one order and executed in another. Every "unknown column" error and every "why doesn't my window function work in WHERE" question traces back to this:
JOINs are where most beginners freeze on the job. Learn all six types and the difference between filtering in WHERE versus ON.
Asked in roughly 80% of mid-to-senior data interviews. Drill them until you can choose between RANK, DENSE_RANK, and ROW_NUMBER without thinking.
Syntax varies by dialect. SQLite uses strftime; Postgres uses EXTRACT and DATE_TRUNC; MySQL uses YEAR(), MONTH(). SQL Quest runs SQLite — challenge hints call out dialect differences.
Things that work but mark you as a beginner in code review. Avoid them once you can.
200+ challenges, AI Coach by Claude, free core forever. First query in under 60 seconds.
Open SQL Quest — Free ⚡Browser-only · No install · No card
Long-form guides with a quick self-check quiz in each — test yourself, then practice the topic for real.
LEFT JOIN vs INNER JOIN
40 vs 46 rows on the same data — the difference in actual rows, plus the WHERE-vs-ON trap.
What is a CTE?
A subquery with a name — the whole concept in one query, plus the scoping trap.
Recursive CTEs explained
Anchor, step, stop — org charts walked both directions, and the infinite-loop trap.
SQL JOINs, every type
INNER to anti-joins, the WHERE-vs-ON bug, with a 3-question self-check.
Window functions from zero
OVER, PARTITION BY, RANK vs ROW_NUMBER — the interview essentials.
CTEs (WITH clauses)
Named subqueries, the column-scoping trap, when recursion earns its keep.
GROUP BY, properly
The grouping contract, WHERE vs HAVING, COUNT(*) vs COUNT(col).
NULL handling mistakes
Why = NULL never matches, propagation, COALESCE patterns.
CASE WHEN patterns
Branch order, the missing-ELSE NULL, conditional counting.
SQL for fraud analytics
Velocity checks, rolling windows, self-joins on real banking shapes.
AI-company interview SQL
Top-N per group, cohort retention, NTILE — what the loops actually ask.
Time-series SQL
Running totals, LAG, moving-average frames for metrics questions.