Subscription Churn Rate by Plan
Problem
**[Asked at Apple]**
Per plan, compute: total subscriptions, churned count, churn rate (%),
and average days to churn (NULL if no churned subs).
Return `plan`, `total`, `churned`, `churn_rate` (2 dp), `avg_days_to_churn`
(2 dp). Order by plan.
Tables
Example rows — the live problem includes the full dataset.
subscriptions
| user_id | started_at | cancelled_at | plan |
|---|
Expected output
Your answer should return 2 rows with the columns plan, total, churned, churn_rate, avg_days_to_churn.
Starter code (SQL)
SELECT *
FROM subscriptions;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock