SQL guides
Short pieces on the mistakes that return a believable wrong answer. Every example runs in the page against the same practice database.
- Why your LEFT JOIN acts like an INNER JOIN2 min
- Why COUNT and SUM are too high after a JOIN2 min
- Why NOT IN returns nothing when the list contains NULL2 min
- WHERE vs HAVING, and when the choice changes your answer2 min
- ROW_NUMBER vs RANK vs DENSE_RANK2 min
- How to get the top N rows per group in SQL2 min
- Running totals in SQL, and the ROWS vs RANGE trap2 min
- Finding consecutive days in SQL (gaps and islands)2 min
- SQL interview questions for data analysts, with runnable answers2 min