Country-Standardized Retention Gap for Users Who Join a Group Early
Last updated: November 29, 2026
Quick Overview
Compare Day-30 retention for new Facebook users who joined at least one Group in their first week against those who did not, then compute a country-standardized difference that weights each country's gap by the early joiners' country mix, so the comparison is not driven by country composition.
Meta
November 29, 20260
0
0 solved
Compare Day-30 retention for new Facebook users who joined at least one Group in their first week against those who did not, then compute a country-standardized difference that weights each country's gap by the early joiners' country mix, so the comparison is not driven by country composition.
Groups is one of Facebook's strongest retention drivers, and leadership often asks how big the gap is between early joiners and everyone else. In the onsite SQL round, the interviewer wants more than a raw difference: per-stratum comparison, a weighted aggregate, and protection against small strata, all in SQL.
What the Interviewer Expects
- Build per-user treatment and outcome flags with correct windows
- Compute rates per country and group
- Drop or flag countries lacking both groups
- Weight country gaps by treated-group share to get a standardized gap
- Contrast raw and standardized gaps and explain the difference
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
- Why weight by the treated group's mix rather than all users?
- What other confounders would you stratify on, and when does stratifying break down?
- How would you estimate a confidence interval for the standardized gap?
- How could an experiment answer the question instead?
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
users(user_id, signup_date, country), group_joins(user_id, join_ts), daily_active(user_id, ds). Early joiner: a join on days 0 to 6. Retention: activity on days 28 to 34. Strata with fewer than ...
Approach
Step 1, flags per user. Step 2, per country and flag, count users and retained. Step 3, pivot to one row per country with both rates and the treated count. Step 4, the standardized gap is $\sum_c w_c ...