1

指标概况 --活跃率--留存率

https://blog.csdn.net/xiao4816/article/details/140244631?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522A5285920-BB13-4457-8E69-98798293C098%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=A5285920-BB13-4457-8E69-98798293C098&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-10-140244631-null-null.142^v100^pc_search_result_base1&utm_term=%E7%95%99%E5%AD%98%E7%8E%87&spm=1018.2226.3001.4187 

 

 

留存率

select
    first_date as install_dt,
    T1.*,ACTIVATE.*
from (
    select 
        player_id,
        min(event_date) as first_date
    from activity group by player_id
) t1 left join activity
on t1.player_id = activity.player_id 
and datediff(activity.event_date, t1.first_date) = 1
group by first_date;

如下是 T1和 activity left关联出来的数据作为参考。
| install_dt | player_id | first_date | player_id | device_id | event_date | games_played |
| ---------- | --------- | ---------- | --------- | --------- | ---------- | ------------ |
| 2016-03-01 | 1 | 2016-03-01 | 1 | 2 | 2016-03-02 | 6 |
| 2017-06-25 | 2 | 2017-06-25 | null | null | null | null |


作者:uccs 链接:https:
//leetcode.cn/problems/game-play-analysis-v/solutions/1276100/si-chong-fang-fa-xiang-xi-jiang-jie-you-445bf/ 来源:力扣(LeetCode) 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 分析 需要几个值 每个玩家第一个登录日 第一个登陆日之后有没有登录 第一个登录日的玩家的数量,第一个登录日的第二天登录玩家的数量 SQL:方法一 select first_date as install_dt, count(*) installs, round(count(activity.event_date) / count(*), 2) as day1_retention from ( select player_id, min(event_date) as first_date from activity group by player_id ) t1 left join activity on t1.player_id = activity.player_id and datediff(activity.event_date, t1.first_date) = 1 group by first_date;
解析
1. 每个玩家第一个登录日,作为 t1 表
select player_id, min(event_date) as first_date from activity group by player_id; 需要得到每个玩家第一个登陆日之后第二天有没有登录 将 t1 表和 activity 左连 这要注意输出的字段 event_date 是第一天登录之后第二天又登录的玩家日期 select * from t1 left join activity on t1.player_id = activity.player_id and datediff(activity.event_date, t1.first_date) = 1; 查询 t1 和 activity 左连后的表,按照第一个登陆日进行分组 first_date count(*) 第一个登陆日的总人数 count(activity.event_date) 第二个登录日的人数 a/b 是第一天玩家的留存率 SQL:方法二 作者:uccs 链接:https://leetcode.cn/problems/game-play-analysis-v/solutions/1276100/si-chong-fang-fa-xiang-xi-jiang-jie-you-445bf/ 来源:力扣(LeetCode) 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

 

 

 

活跃率

posted @ 2024-08-26 17:48  萌哥-爱学习  阅读(9)  评论(0编辑  收藏  举报