SQL and data interview questions
Queries against realistic data: joins that multiply rows, windows, deduplication, and checking the answer before you trust it.
- After a join was added, revenue came out far too high. Find and fix the fan-out.
- For each ticket, return only its most recent status.
- Write a running total of revenue per customer by day.
- Compute the monthly return rate by first-purchase cohort.
- Group page views into sessions separated by a period of inactivity.
- This query got slow after the table grew. Read the plan and say what you would change.