#96. [LeetCode / MySQL] 550. Game Play Analysis IV

문제

 

입력 코드

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))
  IN (
      SELECT 
        player_id, 
        MIN(event_date) AS first_login 
        FROM Activity 
        GROUP BY player_id
  )

 

코드 설명

#SELECT #ROUND #COUNT #DISTINCT #DATE_SUB #INTERVAL #MIN #GROUP BY 

 

 

문제 출처

 

Game Play Analysis IV - LeetCode

Can you solve this real interview question? Game Play Analysis IV - Table: Activity +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +---------

leetcode.com