SQL Retention Analysis

The same cohort framing as before, now asking 'how many are still with us' instead of 'how many left.'

What & Why

Retention analysis usually means the same cohort-grouped query as churn analysis, just reading the "still active" count instead of the "churned" count — same data, different framing for the same conversation.

See How It Works

BUSINESS QUESTION

Growth wants retention percentages for every cohort month and period.

cohort_monthperiod_numberusersretained
2024-01-010420420
2024-01-011420268
2024-01-012420214
2024-02-010510510
EXAMPLE QUERY
SELECT
  cohort_month,
  period_number,
  users AS cohort_users,
  retained,
  ROUND(100.0 * retained / NULLIF(users, 0), 2) AS retention_rate
FROM growth.cohort_retention
ORDER BY cohort_month, period_number;
RESULT — retention by cohort period
cohort_monthperiod_numbercohort_usersretainedretention_rate
2024-01-010420420100.00
2024-01-01142026863.81
2024-01-01242021450.95
2024-02-010510510100.00

The result uses the same real cohort rows shown in the source table.

This lesson's practice is part of Pro.

Advanced business practice

Sign up free to try it on a real business scenario