Compute Day-1 Retention for Each Player Install Date

Quick Overview

Given a table of daily player logins, report for each install date how many players installed that day and the share of them who logged in again on the next calendar day, rounded to two decimals. It tests first-event logic per user, date arithmetic in SQL, and keeping players who never returned in the denominator.

Compute Day-1 Retention for Each Player Install Date

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

Each row of `Activity` records one day on which a player logged in to a game. A player's install date is the first day they logged in. The day-1 retention of a date `x` is the number of players who installed on `x` and also logged in on the day after `x`, divided by the number of players who installed on `x`. For every install date, report how many players installed on that date and the day-1 retention for that date, rounded to 2 decimal places. ```hint Order of steps Settle each player's install date before you aggregate anything by date. ``` ### Input Table(s) Table `Activity` | Column | Type | Meaning | |---|---|---| | player_id | INT | Player identifier. NOT NULL. | | device_id | INT | Device the player logged in from. NOT NULL. | | event_date | DATE | Day of the login. NOT NULL. | | games_played | INT | Games the player played that day, 0 or more. NOT NULL. | Primary key: `(player_id, event_date)`, so a player has at most one row per day. ### Output Contract One row per install date, with these columns in this order: | Column | Type | Meaning | |---|---|---| | install_dt | DATE | A date on which at least one player installed. | | installs | INT | Number of players whose install date is `install_dt`. | | Day1_retention | NUMERIC | Players installed on `install_dt` who logged in on the following calendar day, divided by `installs`, rounded to 2 decimal places. | Order the rows by `install_dt` ascending. Each install date appears once, so this ordering is unique. ### Example `Activity`: | player_id | device_id | event_date | games_played | |---|---|---|---| | 1 | 10 | 2024-01-01 | 3 | | 1 | 10 | 2024-01-02 | 0 | | 2 | 11 | 2024-01-01 | 5 | | 2 | 11 | 2024-01-03 | 2 | | 3 | 12 | 2024-01-01 | 1 | | 4 | 13 | 2024-01-02 | 4 | | 4 | 14 | 2024-01-03 | 2 | | 5 | 15 | 2024-01-04 | 6 | Expected output: | install_dt | installs | Day1_retention | |---|---|---| | 2024-01-01 | 3 | 0.33 | | 2024-01-02 | 1 | 1.00 | | 2024-01-04 | 1 | 0.00 | Players 1, 2 and 3 installed on 2024-01-01. Only player 1 logged in on 2024-01-02 (with zero games, which still counts), so the retention is 1/3, shown as 0.33. Player 2 came back on 2024-01-03, two days after installing, which does not count. Player 4 installed on 2024-01-02 and logged in on 2024-01-03 from a different device, giving 1.00. Player 5 installed on 2024-01-04 and never returned, giving 0.00. Nobody installed on 2024-01-03, so that date has no row even though players logged in on it. ### Constraints and Clarifications - At most 10,000 rows. `player_id` is between 1 and 100. - No column contains NULL. - Every row counts as a login, including rows where `games_played` is 0. - The next day means the calendar day right after `install_dt`. A return two or more days later does not count toward day-1 retention. - Dates on which nobody installed do not appear in the output. - Show `Day1_retention` with two decimals, for example `0.50`, `1.00` or `0.00`.

Overview: Given a table of daily player logins, report for each install date how many players installed that day and the share of them who logged in again on the next calendar day, rounded to two decimals. It tests first-event logic per user, date arithmetic in SQL, and keeping players who never returned in the denominator.

Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

Each row of Activity records one day on which a player logged in to a game. A player's install date is the first day they logged in. The day-1 retention of a date x is the number of players who installed on x and also logged in on the day after x, divided by the number of players who installed on x.

For every install date, report how many players installed on that date and the day-1 retention for that date, rounded to 2 decimal places.

Input Table(s)

Table Activity

ColumnTypeMeaning
player_idINTPlayer identifier. NOT NULL.
device_idINTDevice the player logged in from. NOT NULL.
event_dateDATEDay of the login. NOT NULL.
games_playedINTGames the player played that day, 0 or more. NOT NULL.

Primary key: (player_id, event_date), so a player has at most one row per day.

Output Contract

One row per install date, with these columns in this order:

ColumnTypeMeaning
install_dtDATEA date on which at least one player installed.
installsINTNumber of players whose install date is install_dt.
Day1_retentionNUMERICPlayers installed on install_dt who logged in on the following calendar day, divided by installs, rounded to 2 decimal places.

Order the rows by install_dt ascending. Each install date appears once, so this ordering is unique.

Example

Activity:

player_iddevice_idevent_dategames_played
1102024-01-013
1102024-01-020
2112024-01-015
2112024-01-032
3122024-01-011
4132024-01-024
4142024-01-032
5152024-01-046

Expected output:

install_dtinstallsDay1_retention
2024-01-0130.33
2024-01-0211.00
2024-01-0410.00

Players 1, 2 and 3 installed on 2024-01-01. Only player 1 logged in on 2024-01-02 (with zero games, which still counts), so the retention is 1/3, shown as 0.33. Player 2 came back on 2024-01-03, two days after installing, which does not count. Player 4 installed on 2024-01-02 and logged in on 2024-01-03 from a different device, giving 1.00. Player 5 installed on 2024-01-04 and never returned, giving 0.00. Nobody installed on 2024-01-03, so that date has no row even though players logged in on it.

Constraints and Clarifications

  • At most 10,000 rows. player_id is between 1 and 100.
  • No column contains NULL.
  • Every row counts as a login, including rows where games_played is 0.
  • The next day means the calendar day right after install_dt . A return two or more days later does not count toward day-1 retention.
  • Dates on which nobody installed do not appear in the output.
  • Show Day1_retention with two decimals, for example 0.50 , 1.00 or 0.00 .