Write a SQL query to analyze customer churn by cohort and identify the top drivers of churn.
Use customer sign-up cohorts through June 2024 and consider churn events from the sign-up date through September 30, 2024. For each churn driver, include the number of affected customers and their average completed orders before churn.
Output
- One row per cohort and churn driver, limited to the top three drivers within each cohort.
- Columns:
cohort_month, churn_driver, churned_customers, cohort_customers, churn_rate_pct, avg_pre_churn_orders, and driver_rank.
- Sort by
cohort_month ascending and driver_rank ascending, with churn count, average orders, and driver name resolving ties.