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
Data Manipulation (SQL/Python)
Data Engineer
Tencent
November 29, 2026
Data Engineer
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

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
SQL aggregation
CTEs
Cohort analysis
Date functions
LEFT JOIN
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 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 Problems
Sample 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
  1. Collapse to distinct (user_id, day) pairs. 2. DAU is a count of users per day. 3. Cohort day is MIN(day) per user. 4. Left join cohorts to the daily table on user_id and `day = cohort_day + 1...

Submit Your Answer
Markdown supported

Related Questions