欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

LeetCode-SQL-550. 游戏玩法分析 IV

程序员文章站 2022-06-11 14:29:04
...

LeetCode-SQL-550. 游戏玩法分析 IV

LeetCode-SQL-550. 游戏玩法分析 IV

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)
相关标签: LeetCode 数据库