First-round SQL tests are narrower than people fear. These six patterns cover most of them.
- Aggregate with a filter after grouping
- Join two tables and keep the rows with no match
- Rank rows within a group
- Find duplicates
- Work out a running total
- Compare this month with the same month last year
Say your reasoning out loud
Interviewers care more about how you narrow a problem than whether the syntax is perfect first time. Talk through the rows you expect before you write anything.