A collection of 8 real-world SQL case studies by Danny Ma covering data cleaning, exploration, and analysis across different business domains.
Each week is a standalone business problem with its own schema, questions, and dataset. The solutions are written in MySQL and follow a consistent structure: understand the data, clean what's broken, answer the business questions, and document the thinking behind every hard problem.
| Week | Business | What It's About |
|---|---|---|
| Week 1 — Danny's Diner | Restaurant | Customer behaviour, visit patterns, loyalty program analysis |
| Week 2 — Pizza Runner | Food Delivery | Data cleaning, runner performance, revenue and profitability |
| Week 3 — Foodie-Fi | Subscription Streaming | Customer journey tracking, churn analysis, payment simulation |
| Week 4 — Data Bank | Digital Banking | Node reallocation, transaction patterns, cloud storage modelling |
| Week 5 — Data Mart | Retail | Data cleaning, before-vs-after impact analysis of a packaging change |
| Week 6 — Clique Bait | E-commerce | Clickstream analysis, product funnel, campaign performance |
| Week 7 — Balanced Tree | Clothing Retail | Sales analysis, product mix, transaction behaviour, stored procedure |
| Week 8 — Fresh Segments | Digital Marketing | Interest segment analysis, data quality, rolling averages |
Every case study folder contains:
- The full SQL solution with comments
- A README covering the business context, key findings, technical decisions, and a Mental Model Forge — the reusable thinking patterns behind each solution
Data cleaning · Window functions · CTEs · Recursive CTEs · Stored procedures · JSON extraction · Generated columns · Funnel analysis · Cohort analysis · Before/after analysis · Rolling averages · Schema design · Percentile calculation · Time-series analysis
All case studies are from 8weeksqlchallenge.com by Danny Ma.