SQL Interview Prep
The patterns interviewers test every time
SQL screens are the highest-repetition test in analytics. The winning prep is drilling the patterns — joins, aggregates, window functions, CTEs — until they are reflex, on a real environment with a clock.
What you will learn
- Identify the five patterns behind most SQL screen questions
- Practice window functions and CTEs under time pressure
- Talk about your SQL approach while typing
What is this?
SQL screens reduce to a handful of patterns: filters and aggregates, joins with grain control, deduplication and ranking (window functions), rolling/time-window calculations, and conditionals for segments. Interviewers watch your approach as much as the output — clean, spoken, correct SQL earns double credit.
Why do you need it?
- Most analyst jobs live and die on SQL daily.
- Window functions are the single differentiator between junior and mid SQL answers.
- Screens are timed and typed, so practice must be too.
Mental model
A musician practicing scales
An analyst drilling SQL patterns
Scales are unglamorous, but fluency at speed is what lets you perform under pressure; SQL patterns are the scales of the analysis trade.
How it works
- Learn the five pattern families and which question each maps to.
- Drill on a real warehouse or SQLite against a database with data.
- Practice narrating your approach: read the question, state the join, explain the window.
- Review each attempt for the elegant versus merely-working solution.
Five families of SQL questions cover most screen prompts.
In production
- A 'top 5 products per category' prompt is a row_number window answer.
- A 'new vs returning users' prompt is a first-purchase CTE plus a join.
- A cumulative-revenue prompt is a SUM() OVER (ORDER BY date).
Best practices
- Restate the question and grain before typing a single word.
- Use CTEs to keep logic legible; interviewers read along.
- Mention edge cases (NULLs, duplicates) even if you do not code them.
Common mistakes
- Joining without thinking about row multiplication — then wondering why counts tripled.
- Using GROUP BY when the ask is a keep-one-row-per-group window question.
- Going silent: the reviewer cannot see your reasoning if you do not speak it.
Debugging tips
- If your answer misses rows, re-read whether the ask wants ALL groups (LEFT JOIN) or only matches.
- If distinct counts look wrong, suspect a fan-out join and check the grain before aggregating.
Interview checkpoint
Quick quiz
Top-N per group is answered with
A running total over time uses