SQL for Data Science Interview Questions for Data Science
35 SQL for Data Science questions with answers for data science roles — 12 easy, 17 medium, 6 hard.
About SQL for Data Science
SQL rounds test whether you can pull and shape data yourself: joins, aggregations, window functions, CTEs, retention and funnel queries, and debugging wrong numbers. Most data science interviews in India include a live SQL test, often the first technical screen. Clean, correct SQL with careful handling of duplicates and NULLs makes a strong impression.
Explain INNER, LEFT, RIGHT and FULL OUTER joins.
Show answer
What are window functions in SQL?
Show answer
What is the difference between ROW_NUMBER, RANK and DENSE_RANK?
Show answer
Write SQL to find the second highest salary in an employees table.
Show answer
Write SQL to find duplicate emails in a users table.
Show answer
What is the logical order of execution of a SQL query?
Show answer
What is the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column)?
Show answer
What is the difference between UNION and UNION ALL?
Show answer
Write SQL to pivot order counts by status into columns using CASE WHEN.
Show answer
Tell me about a time you found a data quality issue using SQL.
Show answer
Tell me about a time you created documentation that helped your team work with data.
Show answer
Write SQL to find the top 3 products by revenue in each category.
Show answer
Write SQL to compute a 7-day rolling average of daily active users.
Show answer
Write SQL to calculate month-over-month revenue growth.
Show answer
What is a CTE and what is a recursive CTE?
Show answer
You added an index but the query is still slow. How do indexes work, and when do they fail to help or even hurt?
Show answer
A query using NOT IN returns zero rows even though matches should exist. What is the likely cause, and how do NULLs behave in SQL?
Show answer
After joining orders with a promotions table, total revenue doubled. What went wrong?
Show answer
Write SQL to find customers who ordered in January 2026 but not in February 2026.
Show answer
What is normalisation, and why are analytics tables often denormalised?
Show answer
What is the difference between a star schema and a snowflake schema?
Show answer
Tell me about a time you had to deliver data under an urgent deadline.
Show answer
How do you pull large data from a SQL database into Pandas efficiently?
Show answer
Write SQL to compute a running total of spend for each user.
Show answer
Your SQL result does not match the number on the official dashboard. How do you resolve it?
Show answer
What is the difference between a subquery and a correlated subquery?
Show answer
Describe a time you had to push back on or prioritise many ad-hoc data requests.
Show answer
Write SQL to show each customer's first order date, last order date and the gap between them in days.
Show answer
A query on a 200 million row table takes 20 minutes. How do you speed it up?
Show answer
Write SQL to compute week-1 retention by signup week.
Show answer
Write SQL to find the median order value per city.
Show answer
Write SQL to compute funnel conversion from visit to cart to purchase.
Show answer
Write SQL to find users who logged in on at least three consecutive days.
Show answer
Every time you rerun yesterday's report, the count of new users changes. What is going on and how do you fix it?
Show answer
Frequently asked questions
How important is SQL for Data Science in Data Science interviews?
SQL rounds test whether you can pull and shape data yourself: joins, aggregations, window functions, CTEs, retention and funnel queries, and debugging wrong numbers. Most data science interviews in India include a live SQL test, often the first technical screen. Clean, correct SQL with careful handling of duplicates and NULLs makes a strong impression.
How should I use the SQL for Data Science sheet?
Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.