Choose the pattern yourself
Use this chapter to check whether you can choose the technique without the chapter name giving it away. Attempt the query before opening the worked solution, then keep a short note on the mistake or assumption that changed your answer.
Decision reference
| Goal | Practice mode |
|---|---|
| Recall syntax | Chapter quick references |
| Recognize recurring problems | Pattern cookbook |
| Solve without a label | Mixed drills |
| Explain performance choices | Diagnosis drills |
| Collect execution evidence | Native PostgreSQL labs |
In this chapter
- Find your next SQL problemFilter questions from StrataScratch, LeetCode, and DataLemur by topic and level.
- Choose the right techniqueTranslate interview wording into candidate query patterns.
- Revision drillsWork through a deliberate sequence of query challenges.
- SQL dialect differencesTranslate common operations between PostgreSQL, BigQuery, and MySQL.
- Largest OlympicsCount distinct athletes, then keep every tied maximum.
- Apple Product CountsReduce device events to one flag per user.
- Spam PostsSee why distinct posts and view records give different percentages.
- Country rank changesRank each period separately before comparing countries.
- Top 5%: thresholds & quotasDistinguish percentile cutoffs from a fixed count of rows.
- Later purchases of new productsCompare later purchases with the complete first-day product set.
- Retention and the denominatorUnderstand why an outer join can be necessary.
- Database interview questionsPractice concise explanations of the concepts behind SQL queries.
- Practice problem indexFind a problem by technique and difficulty, then compare the worked reasoning.
- Sources, scope & coverageUnderstand what the handbook covers and where to verify dialect-specific details.
- Mixed SQL practice with progressive hintsIdentify the grain and technique without being told the pattern in advance.
- Practice: diagnose before optimizingUse symptoms and evidence to choose your next investigation, then compare the reasoning.
- Payments and merchants: SQL interview exercisesRank recent successful payments and preserve merchants without valid events.
Mix the problems
Do not work through ten versions of the same pattern in a row. Mix joins, aggregation, windows, dates, and existence problems so the technique is not obvious from context. When a query fails, keep the smallest input that exposes why and retry it later without the old solution.