Learn SQL, one concept at a time
Standalone tutorials on the SQL topics that trip people up: joins, window functions, CTEs, aggregation, and the interview patterns everyone asks about. Each guide is written as companion reading for the SQL Protocol campaign.
- Guide · 8 min read
SQL Joins Explained: INNER, LEFT, RIGHT, FULL
Plain-English walk-through of INNER, LEFT, RIGHT, and FULL OUTER joins with runnable examples and when to use each.
- INNER JOIN
- LEFT JOIN
- RIGHT JOIN
- FULL OUTER JOIN
- Guide · 10 min read
Window Functions: ROW_NUMBER, RANK, LEAD, LAG
A practical tour of SQL window functions. Learn PARTITION BY, ROW_NUMBER, RANK, DENSE_RANK, LEAD, LAG, and running totals.
- OVER and PARTITION BY
- ROW_NUMBER
- RANK vs DENSE_RANK
- LEAD and LAG
- Guide · 7 min read
GROUP BY and HAVING: The Difference Explained
Why WHERE runs before GROUP BY, why HAVING runs after, and how to stop getting cryptic 'column not in GROUP BY' errors.
- Execution order
- Aggregate functions
- GROUP BY vs DISTINCT
- HAVING vs WHERE
- Guide · 9 min read
Common Table Expressions (CTEs) and Recursion
Use CTEs to break long queries into labeled steps, replace confusing subqueries, and traverse hierarchies with recursive CTEs.
- WITH keyword
- CTE vs subquery
- Multiple CTEs
- Recursive CTEs
- Guide · 8 min read
Subqueries and EXISTS: Correlated vs Non-Correlated
When to reach for a scalar subquery, an IN clause, or EXISTS. Performance notes and common gotchas.
- Scalar subqueries
- IN vs EXISTS
- Correlated subqueries
- NOT EXISTS and NULL
- Interview Prep · 14 min read
15 SQL Interview Questions with Solutions
Fifteen realistic SQL interview problems across joins, aggregation, windowing, and schema design, each with a worked solution.
- Join puzzles
- Top-N per group
- Gaps and islands
- Rolling aggregates
Reading is a warm-up. Practice is the workout.
Sign in to drill these concepts in the live game. Interview Mode gives you timed questions; the Arena puts you against another player on the same problem.