30 SQL Interview Questions, Free
The 30 SQL patterns analyst interviews repeat — JOINs, windows, GROUP BY traps, NULLs, dates, CTEs — indexed by pattern with live practice links.
JOINs (6): fanout revenue trap, self-join manager chain, anti-join churned users, multi-key join dedup, full-outer reconciliation, semi-join EXISTS filter. Windows (8): LAG basket-split gaps, ROW_NUMBER ties, running totals, MoM LAG, first/last per customer, NTILE quartiles, rolling 7d average, LEAD next-action. GROUP BY/HAVING (5): HAVING vs WHERE, nullable-key bucket, multi-column rollup, conditional COUNT, top-N per group. NULLs (4): NOT IN vs NOT EXISTS, COALESCE bucketing, null-rate audit, outer-join null flood. Dates (4): cohort matrix, weekday split, days-between with NULLs, rolling retention. CTEs (3): 3-level nest refactor, recursive org chart, CTE + window combo.
Solve all 30 live with solutions at Topfolio Practice.
Related: Sql Rank Dense Rank Tie Traps · Sql Window Function Traps · Data Analyst Interview Questions 2026
Frequently Asked Questions
Are these on clean or messy data?
Messy — missing dates, duplicate keys, inconsistent categories. Clean textbook tables never appear in real interviews.
How should I work through the 30?
By pattern, not in order: master JOINs, then windows, then GROUP BY traps, then NULLs, dates, and CTEs. Depth per pattern beats breadth.
How is this different from the interview-questions guide?
That guide covers full interview loops and companies; this page is the SQL-only drill index by pattern.

Written by
Founder at Topfolio with 6+ years in data & analytics across JPMC, Ultrahuman, and high-growth startups. Sat on hiring panels, reviewed 500+ resumes, and writes practical SQL & data guides.
Related Articles
30 SQL Interview Questions for Freshers & Analysts (2026)
Master top 30 SQL interview questions for freshers and analysts. Includes verified SQL queries for JOINs, Window Functions, CTEs, and GROUP BY.
5 Window Traps That Lie
Basket-split LAG gaps, ghost orders, nondeterministic ROW_NUMBER, RANK gaps, unframed running totals: 5 window traps with fixes and SQL included.
4 GROUP BY Traps, Wrong vs Right
WHERE vs HAVING, nullable grouping keys, bare SELECT columns: 4 GROUP BY traps that run without errors yet fail take-homes, each with the fix.