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
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

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
Growth accounting
Self-join
Anti-join
Cohorts
Accounting identity
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. 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 Problems
Sample Answer
Clarify the Data

Table: user_activity(user_id, activity_date). Definitions for month mm:

  • new: active in mm, and mm is their first active month
  • retained: active in mm and in m−1m-1
  • resurrected: a...
Approach
  1. Distinct (user, month).
  2. Each user's first month.
  3. Left join each user-month to the same user's previous month to classify active users.
  4. Separately, find user-months with no following month,...

Submit Your Answer
Markdown supported