Customer Churn Analysis — End-to-End SQL + Python Case Study
A complete churn analysis walkthrough — data exploration, cohort analysis, churn segmentation, and a business recommendation. The exact format asked in product company interviews.
A food delivery app has seen monthly active users decline for 3 consecutive months. Your task: identify who is churning, when, and why — then recommend a retention intervention.
Step 1 — Define Churn
Before writing any SQL, align on the definition. Churn = user who was active in month M but made zero orders in month M+1.
- Active = at least 1 order
- Churn window = 30 days of inactivity
- Exclude new users from churn calculation
Step 2 — Explore the Data
Understand the dataset before analysing it. Check row counts, null rates, date ranges, and user distribution.
- Total users and active users per month
- Order frequency distribution
- Null checks on key columns
Step 3 — Segment Churners
Not all churners are equal. High-value churners need different treatment than low-frequency users who naturally lapse.
- Segment by order frequency before churn
- Segment by city / platform
- Identify the highest-LTV churners first
Find users who ordered in month M but not in M+1. This is the core churn definition query.
Classify churners into High / Medium / Low value segments based on their order count before churning.
Interviewers want to see you go beyond the analysis to a concrete, prioritised recommendation.
Priority 2 — Early churn (churned after 1-2 orders): These users never formed a habit. Invest in Day-3 and Day-7 onboarding push notifications and an offer on the second order to build the habit.
Guardrail: Monitor margin — discount campaigns can recover revenue gross but destroy unit economics if not capped.
Want to practise case studies like this?
Book a free mock case study session — we’ll walk you through a real dataset and give live feedback on your analysis and recommendation.
Book Free Case Study Mock