Unit 8: SQL interview problems, from easy to hard

Solve the classic SQL interview questions from a blank page, explain your approach while you write, and name the edge cases before the interviewer does.

The big picture

Most SQL interview questions are one of about a dozen patterns: Nth highest, top N per group, rows with no match, duplicates, comparisons with a group average, period-over-period change, first event per user, streaks, retention. Learn to spot the pattern from the wording, and the query almost writes itself.

Lessons in this unit