Churn rate by cohort is the most honest measure of retention health in a subscription business. This query tracks the percentage of customers who become inactive within each signup cohort.
This is part of the Taptic Data Database query library. Explore related queries: SQL query for monthly revenue trend, SQL query for top customers by revenue, SQL query for revenue by region, and more.
The question
The SQL Taptic generates
WITH cohorts AS ( SELECT customer_id, DATE_TRUNC('month', signup_date)::date AS cohort_month FROM customers ), activity AS ( SELECT customer_id, MAX(order_date)::date AS last_active FROM orders WHERE status NOT IN ('cancelled', 'refunded') GROUP BY customer_id ) SELECT TO_CHAR(c.cohort_month, 'YYYY-MM') AS cohort, COUNT(*) AS cohort_size, COUNT(*) FILTER ( WHERE a.last_active < CURRENT_DATE - INTERVAL '90 days' OR a.last_active IS NULL ) AS churned, COUNT(*) FILTER ( WHERE a.last_active >= CURRENT_DATE - INTERVAL '90 days' ) AS still_active, ROUND( COUNT(*) FILTER ( WHERE a.last_active < CURRENT_DATE - INTERVAL '90 days' OR a.last_active IS NULL ) * 100.0 / NULLIF(COUNT(*), 0), 1 ) AS churn_rate_pct FROM cohorts c LEFT JOIN activity a USING (customer_id) WHERE c.cohort_month >= NOW() - INTERVAL '12 months' AND c.cohort_month < DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '3 months' GROUP BY c.cohort_month ORDER BY c.cohort_month ASC
This query was generated by Taptic Data from plain English against a real Any SQL database schema. In Taptic, you type the question โ the AI writes the SQL, runs it, and returns the result. You can edit the SQL, ask for explanations, and save it as a refreshable report.
How this query works
What it returns
Monthly cohort table with cohort size, churned count, still-active count, and churn rate percentage โ covering cohorts old enough to have meaningful churn data.
Why it matters
FAQ
Generate this automatically
In Taptic Data, you type "Show me customer churn rate by signup month cohort for the l..." and this SQL runs automatically against your real Any SQL database data.
Try Taptic Free โ $29.99/moNo credit card required. Connect your data source in under 5 minutes.
Compare tools