21 questions · Data Analyst

SQL Interview Questions for Data Analysts

A practical SQL question bank for hiring data analysts — joins, aggregation, window functions, and the analytical judgement that separates someone who writes queries from someone who answers questions with data.

For a data analyst, SQL is the instrument, not the job. The job is turning a vague business question into a precise query and then into an answer someone can act on. So while you do need to confirm a candidate can write correct joins and aggregations, the more valuable signal is whether they think analytically: do they ask what the question really means, notice when a result looks wrong, and understand the difference between "the query ran" and "the answer is right"? The questions below build from core SQL mechanics up to applied scenarios. Use the early ones to confirm fluency — a strong analyst should explain the difference between an INNER and LEFT JOIN without hesitation — and the later ones to see how they handle ambiguity and messy data. Many real analytics bugs come from quietly dropped rows, double-counted joins, or NULLs behaving unexpectedly, so reward candidates who mention those risks unprompted. A practical exercise against a sample schema, paired with two or three of these discussion questions, gives a clear read on whether someone can be trusted with the numbers the business decides on.

How to use these questions

Confirm fluency with two or three Core SQL questions, then spend most of the interview on the Applied Scenarios — ideally against a small sample schema the candidate can query live. The strongest signal is an analyst who validates their own results and flags where the data could mislead, not just one who returns a syntactically correct query.

Core SQL

  1. Explain the difference between an INNER JOIN and a LEFT JOIN with a real example.
  2. What is the difference between WHERE and HAVING?
  3. How does GROUP BY work, and what happens to columns not in the GROUP BY or an aggregate?
  4. What is the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT column)?
  5. How do NULL values behave in comparisons, joins, and aggregate functions?
  6. What is the difference between UNION and UNION ALL, and why does it matter for performance?
  7. In what logical order does SQL execute the clauses of a SELECT statement?

Window Functions & Advanced

  1. What is a window function, and how is it different from a GROUP BY aggregation?
  2. How would you rank rows within a group — and what is the difference between RANK, DENSE_RANK, and ROW_NUMBER?
  3. How would you calculate a running total or a 7-day moving average in SQL?
  4. How would you find the second-highest salary in each department?
  5. When would you use a CTE over a subquery, and does it change performance?

Performance & Data Quality

  1. A query is slow. What do you check first, and how do indexes help?
  2. How could a JOIN accidentally inflate your row count, and how would you catch it?
  3. How do you validate that a query result is actually correct before you report it?
  4. How would you find and handle duplicate rows in a table?

Applied Analytical Scenarios

  1. A stakeholder asks "how many active users did we have last month?" — what questions do you ask before writing the query?
  2. Write a query to find the monthly retention rate of new signups. Walk me through your logic.
  3. Revenue looks 20% lower this week than last. How would you use SQL to investigate?
  4. How would you measure conversion from signup to first purchase?
  5. Tell me about an analysis where the data turned out to be misleading. What did you do?

Tips for interviewing SQL candidates

  • Give candidates a small sample schema to query live — applied SQL reveals more than whiteboard recall.
  • Reward candidates who clarify the business question before writing SQL; that is the core analyst skill.
  • Watch for awareness of NULLs and join inflation — these cause most real-world reporting bugs.
  • Ask how they validate results; trustworthy analysts double-check before they report.
  • Pair one technical question with one "tell me about a misleading dataset" story for a rounded read.

Frequently asked questions

Hiring data analysts? JuggleHire screens for real SQL skill before you interview.

JuggleHire goes beyond simple job posting. Leverage custom forms, powerful screening filters, and automated social media previews to find the perfect fit for your team.