550. 游戏玩法分析 IV
编写一个 SQL 查询,==报告在首次登录的第二天再次登录的玩家的比率,四舍五入到小数点后两位。==换句话说,您需要计算从首次登录日期开始至少连续两天登录的玩家的数量,然后除以玩家总数。
查询结果格式如下所示:
# select
# round(count(*)/(select count(distinct player_id) from Activity) , 2) as fraction
# from
# Activity as a join Activity as b on a.player_id = b.player_id and a.device_id=b.device_id
# where
# b.event_date=a.event_date+1
# group by
# a.player_id,
# a.device_id
select
round(count(player_id)/(select count(distinct player_id) from Activity) , 2) as fraction
from
Activity
where
(player_id,event_date) in
(select
player_id,date(min(event_date) + 1)
from
Activity
group by
player_id)