Build a Monthly Paying Cohort Retention Matrix for Google One
Last updated: November 29, 2026
Quick Overview
From Google One subscription charge records, assign each subscriber to the month of their first successful payment and report, for each cohort and month offset, how many subscribers paid and what percentage of the cohort that is.
0
0
0 solved
From Google One subscription charge records, assign each subscriber to the month of their first successful payment and report, for each cohort and month offset, how many subscribers paid and what percentage of the cohort that is.
Google One is a subscription business, so cohort retention by first paid month is a staple of its analytics. Onsite interviewers use this to see whether you define the cohort from clean paying events, compute month offsets correctly, and avoid reporting partial months as churn.
What the Interviewer Expects
- Define activity as a successful nonzero charge and dedupe to user-month
- Assign cohort as the first paid month
- Compute month offset with DATE_DIFF in MONTH units
- Divide by cohort size taken from month 0
- Exclude the in-progress month
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
- Annual plan subscribers pay once a year. How does that distort this matrix and how would you fix it?
- How would you compute revenue retention instead of user retention?
- How would you compare cohorts that started on a free trial with those that did not?
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
google_one_charges(user_id, charged_at, amount_usd, status, plan). Refunds and failed retries are separate rows with other statuses. A free trial creates a zero-dollar row, which I exclude so the co...
Approach
- Distinct user and paid month.
- Cohort month is the minimum paid month per user.
- Join back, compute
month_number = DATE_DIFF(paid_month, cohort_month, MONTH)and count distinct users per coho...