Top 30 SQL Interview Questions
A practical checklist of SQL topics and question patterns for data analyst, BI, and engineering interviews.
10 min read
What interviewers usually test
SQL interviews test more than syntax. They measure whether you can turn an ambiguous business question into a correct, readable, and efficient query.
- Filtering, sorting, and NULL handling
- INNER, LEFT, and self joins
- GROUP BY, HAVING, and conditional aggregation
- CTEs and subqueries
- Window functions
- Date, cohort, retention, and ranking problems
The 30-question checklist
Practice these patterns using real tables rather than memorizing isolated answers.
- Find duplicates and explain how you would remove them
- Return the second-highest salary
- Compare each employee with the department average
- Find customers with no orders
- Calculate monthly revenue and month-over-month growth
- Rank products within each category
- Build a running total
- Find the first and latest event per user
- Calculate a seven-day moving average
- Identify consecutive login days
- Measure conversion between funnel steps
- Calculate cohort retention
- Find gaps in a sequence
- Pivot categories with conditional aggregation
- Explain WHERE versus HAVING
- Explain UNION versus UNION ALL
- Explain ROW_NUMBER, RANK, and DENSE_RANK
- Explain EXISTS versus IN
- Handle NULL safely
- Use CASE for business rules
- Join more than two tables without duplicating totals
- Find a median or percentile
- Calculate share of total
- Compare current and previous rows with LAG
- Find overlapping date ranges
- Deduplicate while keeping the latest record
- Explain indexes at a practical level
- Read a query execution plan
- Improve a slow aggregation query
- Validate results with edge cases
How to practice
State your assumptions, write the simplest correct query, test edge cases, and then improve readability or performance. SQL Master lets you run the query, compare results, use hints, and review an alternative solution.
Turn the concept into practice
Write real queries, run them safely, and compare the result with a verified solution.
Open Practice Arena