Create a CTE named first_logins
to select the minimum event_date
for each player_id
from the Activity
table, grouping by player_id
.
Create a CTE named consec_logins
to count the number of players who logged in the day after their first login. This is done by joining the first_logins
CTE with the Activity
table on player_id
and checking if the event_date
from Activity
is one day after the first_login
date.
In the final SELECT statement, calculate the fraction by dividing the count of consecutive logins by the total count of players from the first_logins
CTE. Round the result to two decimal places.
Return the result as a single column named fraction
.
erDiagram Activity { int player_id int device_id date event_date int games_played player_id event_date PK }