Cohort and Funnel Queries
Answer retention questions.
What Is a Cohort?
A cohort is a group of users who share a starting event, usually their signup month. Tracking each cohort over time reveals true retention.
Aggregate metrics hide churn; cohorts expose whether new users actually stick around.
SELECT user_id,
DATE_TRUNC('month', signup_date) AS cohort_month
FROM users;Defining the Cohort
The first step is labeling each user with their cohort. DATE_TRUNC rounds signup dates down to the month so users group cleanly.
Store this as a reusable building block for everything that follows.
SELECT DATE_TRUNC('month', signup_date) AS cohort_month,
COUNT(*) AS cohort_size
FROM users
GROUP BY 1
ORDER BY 1;All lessons in this course
- Why Marketers Learn SQL
- SELECT, WHERE, GROUP BY
- Joining Marketing Tables
- Cohort and Funnel Queries