SQL that answers the question you were asked
The SQL round is not testing syntax, it is testing whether your query means what you think it means. This runs three queries that return confident wrong answers — a join that inflates revenue by 84%, a "never redeemed" filter that returns nothing because of one NULL, and a first-purchase query with a tie — and the window-function patterns that get each one right.
What you'll be able to do
- Recognise join fan-out and fix it by pre-aggregating the one-to-many side
- Explain why NOT IN against a nullable subquery returns nothing, and write the anti-join instead
- Use ROW_NUMBER, LAG, and a windowed SUM to answer per-entity questions in one pass
- State the clarifying questions and the sanity checks that belong in every SQL answer
Before this: cohorts-that-are-not-lying-to-you
The rest of this lesson is in the app
The SQL round is not testing syntax, it is testing whether your query means what you think it means. This runs three queries that return confident wrong answers — a join that inflates revenue by 84%, a "never redeemed" filter that returns nothing because of one NULL, and a first-purchase query with a tie — and the window-function patterns that get each one right. This walkthrough runs about 28 minutes, with runnable code you can edit and re-run as you read.
Continue in ChannelPulseThe first module of every track is free to read on the web — see what's open in Data science.