Image Alt photo_exhibition

Write a solution to report the fraction of players that logged in again on the day after the day they first logged in, rounded to 2 decimal places. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.

The result format is in the following example.

Image Alt photo_exhibition

SELECT
  ROUND(COUNT(DISTINCT player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) AS fraction
FROM
  Activity
WHERE
  (player_id, DATE_SUB(event_date, INTERVAL 1 DAY)) --- event_date, event_date + 1 DAY
  IN (
    SELECT player_id, MIN(event_date) AS first_login -- 가장 처음 플레이한 날짜(MIN)
    FROM Activity 
    GROUP BY player_id
  )