Weekly Retention Cohorts for New ChatGPT Plus Subscribers
Last updated: November 29, 2026
Quick Overview
Given a subscriptions table and a messages table, write SQL that groups users by the week of their first Plus subscription and reports, for each cohort and each week offset, how many cohort members sent at least one message and the retention rate.
OpenAI
November 29, 20260
0
0 solved
Given a subscriptions table and a messages table, write SQL that groups users by the week of their first Plus subscription and reports, for each cohort and each week offset, how many cohort members sent at least one message and the retention rate.
Subscription growth and engagement for ChatGPT Plus are watched closely, and cohort tables are the bread and butter of the data science screen. The interviewer checks cohort definition, week bucketing, distinct counting, and choosing the right denominator.
What the Interviewer Expects
- Defines the cohort by the first qualifying subscription only
- Buckets dates to week starts consistently
- Counts distinct users per offset, not messages
- Computes the denominator from the full cohort, not only active users
- Excludes activity from before the subscription began
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you show retention as paid retention (still subscribed) instead of message activity?
- How do you handle cohorts that are too young to have a week 4 value yet?
- How would you turn this into a cohort triangle with weeks as columns?
- What changes if users can cancel and resubscribe?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
subscriptions(user_id, plan, started_at): a user can have several rows (resubscribes, other plans).messages(user_id, sent_at): one row per user message.- Cohort = Monday of the week of the u...
Approach
MIN(started_at)per user for planplus.- Snap to the Monday of that week.
- Cohort sizes from that table alone, so the denominator includes users who never came back.
- Distinct (user, week...