Skip to main content

Interview prep

Data Analyst SQL Interview Questions

SQL is tested in almost every data analyst interview, usually as a live exercise on tables like customers, orders and payments. Below are real interview-style questions grouped by what interviewers test. Each one runs on a real database, so you can practise writing the query, not just reading the answer.

1. Aggregation and GROUP BY questions

The most common category. Expect revenue by month, average order value per customer segment, or counts with a HAVING filter. Interviewers check that you group by the right columns and filter in the right place.

Practise all SQL GROUP BY questions →

2. JOIN questions

Combining customers, orders and products. The classic: find customers who never placed an order. Know when a LEFT JOIN is needed and how joins can duplicate rows.

Practise all SQL JOINs questions →

3. Subquery and CTE questions

Multi-step questions: compare each row with an average, find the second-highest value, or build a result in stages. Clear CTEs make your reasoning easy to follow.

Practise all SQL Subquery questions →

4. Window function questions

Top N per group, running totals, ranking with ties, month-over-month growth with LAG. The topic that most often separates strong candidates.

Practise all SQL Window Functions questions →

5. Business case questions

Open problems like churn, retention, cohorts or funnel drop-off. There's no single keyword to spot. You choose the approach and explain it.

Practise all Interview-Level SQL questions →

How to answer a SQL interview question

    1. Restate the question

    Say what you think is being asked and which tables you'll need.

    2. Clarify the edge cases

    Do cancelled orders count? What about ties, NULLs or customers with no activity?

    3. Plan in steps

    Outline the query (filter, join, group, rank) before typing. CTEs make the plan visible.

    4. Write and run it

    Build the query one step at a time and look at the intermediate results.

    5. Sanity-check the answer

    Does the row count make sense? Would a stakeholder trust this number?

FAQ

What SQL questions are asked in data analyst interviews?
Mostly aggregations with GROUP BY and HAVING, JOINs (especially finding rows with no match), subqueries and CTEs for multi-step logic, and window functions for rankings, top N per group, running totals and period-over-period change. Senior roles add open business cases like retention or cohorts.
How should I prepare for a SQL interview?
Practise on realistic tables rather than memorising syntax. Solve a few questions per topic, then mix them. For each answer, say your assumptions out loud and check the result. Timed practice on medium and hard questions is the closest thing to the real interview.
Which SQL dialect do interviews use?
Usually standard SQL that works in PostgreSQL, MySQL, SQLite or BigQuery with small changes. The concepts (joins, grouping, window functions) are the same everywhere; only date functions differ much between databases.
Are these interview questions free?
Yes. With a free Google sign-in you can solve 10 new problems every week. SQLSolve Pro unlocks every problem, the reference solutions and unlimited AI hints.

Practise like it's the real interview

412 questions on real e-commerce, finance and healthcare data. Free to start.

Start practising