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.

Vespera mentors7 min read · Interviews

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

Free career call

Your next move, made clear

Tell us two things and book a free 45-minute career call. You leave it with a plan, whether or not you go ahead.

  • An honest read of your profile
  • Target roles and cities for your skills
  • Fees in writing before you commit

1The role you want next

2Where your search stands

Book a career call

Free · 45 minutes · over video