Find Messenger Users Who Came Back After a Thirty-Day Dormant Gap
Last updated: November 29, 2026
Quick Overview
From a Messenger daily activity table, find every resurrection event (an active day that follows at least 30 inactive days), then report per month the number of resurrections and the share of resurrected users who were active again within the following 7 days.
Meta
November 29, 20260
0
0 solved
From a Messenger daily activity table, find every resurrection event (an active day that follows at least 30 inactive days), then report per month the number of resurrections and the share of resurrected users who were active again within the following 7 days.
Messenger growth teams track resurrected users separately from new and retained users because win-back notifications and re-engagement campaigns target them. In a Meta onsite SQL round this tests gaps-and-islands reasoning with LAG plus a second self-join to measure whether the comeback sticks.
What the Interviewer Expects
- Collapse to distinct active days before using LAG
- Define the gap as days between consecutive active days minus one
- Treat each qualifying day as one resurrection event, allowing several per user
- Measure stickiness with an EXISTS on days 1 to 7 after the return
- Exclude returns too recent to have a full 7-day follow-up
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 exclude a user's very first active day, which has no previous day?
- How would you attribute a resurrection to a push notification sent shortly before it?
- How would the query change for a 28-day definition aligned to Meta's monthly actives?
- How would you make this incremental for a daily pipeline?
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
messenger_activity(user_id, ds, sends) may have several rows per day across devices. A dormant gap means at least 30 full days with no activity between two active days. The first day a user ever app...
Approach
Step 1, deduplicate to (user, ds). Step 2, LAG(ds) per user gives prev_ds; a resurrection is a row with date_diff('day', prev_ds, ds) - 1 >= 30. Step 3, for each resurrection check whether the u...