LeetCode-SQL-550. 游戏玩法分析 IV
程序员文章站
2022-06-11 14:29:04
...
SELECT ROUND(COUNT(DISTINCT a1.player_id) / (SELECT COUNT(DISTINCT player_id) FROM Activity), 2) AS fraction
FROM Activity AS a1, Activity AS a2
WHERE a1.player_id = a2.player_id
AND DATEDIFF(a1.event_date, a2.event_date) = -1
AND (a1.player_id, a1.event_date) IN
(SELECT player_id, MIN(event_date)
FROM Activity
GROUP BY player_id)