download

SQL Interview Questions

Practice window functions, join fanout, NULL-safe anti-joins, retention cohorts, composite indexes, and transaction isolation with free SQL interview questions. Each exercise includes hints and a checked query.

SQL13 questionsFree · No sign-in

Practice questions

  1. Top two order amounts per customer, keeping ties · window functions · 15 min
  2. How do you keep customers with no paid orders? · Outer joins · 6 min
  3. Why can NOT IN return no rows? · NULL and anti-joins · 7 min
  4. When should you filter with WHERE or HAVING? · GROUP BY and HAVING · 6 min
  5. Why does joining payments and tickets inflate revenue? · Join cardinality · 9 min
  6. How do you count successes and unknowns in one query? · Conditional aggregates · 7 min
  7. How do you get one latest event per user? · Deterministic window order · 8 min
  8. How do you reset a running total every month? · Running totals and frames · 9 min
  9. How do you calculate day-one retention from repeated events? · Signup cohorts · 10 min
  10. Why did our composite index still scan too many rows? · Composite indexes · 10 min
  11. Two withdrawals both read balance 100. How do you stop overdrafts? · Transaction isolation · 12 min
  12. Why did UNIQUE(email, deleted_at) still allow duplicate active users? · Unique constraints · 10 min
  13. How do you split user events into sessions using LAG()? · LAG and sequence gaps · 10 min

How to practice

Predict the result or explain what you would change before opening the hints. Then compare your reasoning with the answer and try the follow-up question.

Open the interactive SQL deck →