22 - 游戏玩法分析 IV
- 考点: 聚合函数
# 日期相加 date_add(min(event_date),INTERVAL 1 DAY)
select
round(count(distinct player_id)/(select count(distinct player_id) from Activity),2) fraction
from
Activity
where
-- 如果日期加一天的数据能在表中查到,说明连续登录了两天
(player_id,event_date) in
(select
player_id,date_add(min(event_date),INTERVAL 1 DAY)
from
Activity
GROUP BY
player_id
);