- Home
- Courses
- SQL Interview & Case Lab
- Business SQL Patterns
Micro Free Course — 100% Free Learning
All lessons in this module are free to learn. Sign in with Google to save your progress.
Business SQL Patterns
The six business-context SQL patterns DA interviews hit hardest: LTV, cohort retention, funnels, growth rates, top-N per group, and anomaly detection. Every one is a query you'll write hundreds of times.
Module Content
Calculating LTV in SQL — Patterns from Real SaaS
Three flavours of LTV you'll be asked to compute, and the SQL that gets each one right. FIND_VIDEO: search 'customer lifetime value SQL tutorial' — recommended channel: Data with Danny. Aim for 11 min or under.
Recap — LTV Three Ways
Historic LTV, predictive LTV, and cohort LTV — same idea, three different SQL queries.
Cohort Retention Analysis in Pure SQL
Building the retention triangle from raw events — one query, no Python. FIND_VIDEO: search 'cohort retention SQL window functions' — recommended channel: EverSQL / Mode Analytics. Aim for 12 min or under.
Recap — Building a Retention Table
The retention triangle is one CTE chain. Once you've written it, you've written it forever.
Funnel Analysis with Self-Joins and Window Functions
Two ways to write a funnel — self-joins (simple, slow) and window functions (fast, scalable). FIND_VIDEO: search 'SQL funnel analysis conversion' — recommended channel: Mode Analytics. Aim for 12 min or under.
Recap — Funnel SQL Patterns
The most-asked product analytics interview question, with both query patterns and when to use which.
MoM, YoY, WoW — The SQL Patterns
Every BI dashboard has these. LAG() is your friend. Self-joins are not. FIND_VIDEO: search 'SQL month over month growth LAG' — recommended channel: EverSQL. Aim for 10 min or under.
Recap — Running Totals and Growth Rates
The growth-rate patterns every BI dashboard uses, written with LAG and SUM OVER.
Top-N per Group — The RANK / ROW_NUMBER Trap
The single most-asked SQL interview question — with the three subtle wrong-answer traps. FIND_VIDEO: search 'SQL top N per group ROW_NUMBER RANK' — recommended channel: LearnSQL. Aim for 10 min or under.
Recap — Top-N Without Falling Into the Trap
ROW_NUMBER, RANK, DENSE_RANK. Same query shape, three different answers. The interviewer is testing whether you know which.
Anomaly Detection in SQL — Z-Scores and IQR
Flag the day that doesn't belong, in one query, no Python. FIND_VIDEO: search 'SQL anomaly detection z-score window' — recommended channel: Modern SQL. Aim for 11 min or under.
Recap — Flagging Outliers
Two flavours of in-SQL anomaly detection — z-scores for normal-ish data, IQR for skewed data.