Interview Prep

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.

Anuj SainiOct 5, 20261 min read

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.

Anuj Saini

Written by

Anuj SainiFounder & Lead Instructor

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.