Compute Daily Active Users and Next-Day Retention for a Game Launch
Last updated: November 29, 2026
Quick Overview
Given a login events table for a newly launched mobile game, write SQL that reports daily active users per day and, for each install cohort day, the share of new players who came back the next calendar day.
Tencent
November 29, 20260
0
0 solved
Given a login events table for a newly launched mobile game, write SQL that reports daily active users per day and, for each install cohort day, the share of new players who came back the next calendar day.
Tencent Games launches titles across China and global markets and watches DAU and D1 retention closely in the first weeks to judge live-ops health. A data screen like this checks clean date bucketing, cohort definitions and the left join that keeps zero-retention cohorts in the output.
What the Interviewer Expects
- Deduplicates to one row per user per day before counting
- Defines the cohort as each user's first active day
- Uses a LEFT JOIN so cohorts with no returners still appear
- Computes the rate with non-integer division
- Mentions time zone choice for day boundaries
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 extend this to D7 and D30 retention in one query?
- How would you split retention by region or acquisition channel?
- Which time zone should define a day for a global launch?
- How would you make this incremental in a daily pipeline instead of scanning all history?
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 logins(user_id BIGINT, event_time TIMESTAMP, region TEXT), one row per login, many per user per day. Assume event_time is already in the reporting time zone (for a China launch, UTC+8). A ne...
Approach
- Collapse to distinct
(user_id, day)pairs. 2. DAU is a count of users per day. 3. Cohort day isMIN(day)per user. 4. Left join cohorts to the daily table onuser_idand `day = cohort_day + 1...