游戏数据后台设有“登录日志”和“登出日志”两张表。
其中,“角色id”字段唯一识别玩家。
游戏开服前两天(2022-08-13至2022-08-14)的登录日志和登出日志部分数据如下
登录日志
登出日志
1、开服首日(2022-08-13),游戏的DAU和次日留存率
select count(distinct t1.角色id) as DAU, count(distinct t2.角色id)/count(distinct t1.角色id) as 次日留存率
from (select * from 登录日志 where 日期='2022-08-13') t1
left join
(select * from 登录日志 where 日期='2022-08-14') t2
on t1.角色id=t2.角色id
2、玩家在开服首日(2022-08-13)等级分布情况,即每个等级停留的角色数
select 角色id,角色等级
from (select *,rank() over(partition by 角色id order by 时间 desc) rk
from (select 日期,登录时间 as 时间,角色id,角色等级
from 登录日志
where 日期='2022-08-13'
union