As asked
Using SQL, how would you compute the 30-day retention rate for cohorts of users grouped by their signup week? Assume a table 'events' with columns user_id, event_date, and event_type.
Sample answer outline
The candidate should write a query that finds each user's first event date (cohort assignment) using MIN(event_date), joins back to events to find users with activity 28 to 35 days later, and groups by cohort week. They should use date arithmetic correctly, discuss the denominator (cohort size), and mention edge cases like users who only have one event.
Expect these follow-ups
- How would you extend this to compute a full 12-week retention curve without repeating the join 12 times?