Code recipe · Advanced · 15 min
Cohort retention table in SQL
Compute monthly retention by signup cohort in one query.
- ChatGPT
- Claude
- Any assistant
- data
- code
- sql
Inside this code recipe
- Retention by cohort is the chart everyone wants and the query everyone gets subtly wrong; this version counts each subscriber once per month.
- Language
- SQL
The full code recipe opens with a membership that covers AI Data Analysis.
Sign in if you already subscribe.
Sign in
