Classify Monthly Users as New, Retained, Resurrected, or Churned
Last updated: November 29, 2026
Quick Overview
From a daily activity log, write SQL that produces Instagram growth accounting: for each month, counts of new, retained, resurrected, and churned users.
Meta
November 29, 20260
0
0 solved
From a daily activity log, write SQL that produces Instagram growth accounting: for each month, counts of new, retained, resurrected, and churned users.
Growth accounting is how Meta growth teams explain MAU changes: whether growth comes from new users, keeping existing ones, or bringing lapsed users back. The interviewer checks the state definitions, the self-join to the previous month, how churn is attributed to a month, and the identity that ties the states back to MAU.
What the Interviewer Expects
- Defines each state precisely relative to the previous month
- Reduces activity to distinct user-months first
- Joins to the previous month to separate retained from resurrected
- Produces churned users who appear in no row for the current month
- Validates with the MAU accounting identity
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 compute the quick ratio (new + resurrected) / churned?
- How would you do the same with weekly or rolling 28-day windows?
- What if users can delete and recreate accounts?
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
Table: user_activity(user_id, activity_date). Definitions for month :
- new: active in , and is their first active month
- retained: active in and in
- resurrected: a...
Approach
- Distinct (user, month).
- Each user's first month.
- Left join each user-month to the same user's previous month to classify active users.
- Separately, find user-months with no following month,...