The SQL questions that come up in almost every data interview
Six patterns cover most SQL interview questions for analyst and data engineering roles. Know these and you can work through the rest.
The six patterns
- Aggregation with GROUP BY and HAVING: totals, averages and counts per group
- Joins: INNER, LEFT, and finding rows with no match
- Window functions: ROW_NUMBER, RANK, running totals with SUM() OVER
- Top N per group, using a window function and a filter
- Dates: grouping by week or month, comparing periods
- Duplicates and NULLs: finding, counting and handling them
Think out loud
Interviewers care about how you reason as much as the final query. Restate the question, say which tables you need and how they join, then build the query step by step.
How to practise
Practise on a real database rather than on paper, so you see errors and results. After each problem, explain your query in two sentences as if to a non-technical manager. That explanation is often what decides a data interview.
Want a mentor to go through this with you, on your own résumé and roles?
Book a career call