P95SQLIntermediateImplement14 min
Implement a Reproducible SQL Cohort Table
Build a deterministic cohort table from each user's first qualifying event.
#implement#sql#cohorts
Scenario
An events table contains multiple product events per user. Analytics needs a stable monthly acquisition cohort and active-user count by cohort month.
Problem statement
Write a compact SQL query that assigns each user once using their first completed signup, then summarizes cohort size and active users.
Your Task
- Define the user-level cohort grain.
- Use the first qualifying event deterministically.
- Avoid duplicate user assignment before aggregation.
Table
events(user_id, event_at, event_name, event_id)
Related Concepts
SQL CTEsCohort analysisData grain
Ready to count this problem?
Mark it complete when you have reasoned through the solution in your own words.