题解 | #2021年11月每天新用户的次日留存率#

2021年11月每天新用户的次日留存率

https://www.nowcoder.com/practice/1fc0e75f07434ef5ba4f1fb2aa83a450

 select
 a.firstday, round(count(b.uid)/count(a.uid),2) uv_rate
 from(
    (select
    uid, date(min(in_time)) firstday
    from tb_user_log
    group by uid) a
    left join 
    (select uid, date(in_time) utime from tb_user_log
    union
    select uid, date(out_time) utime from tb_user_log) b
    on a.uid = b.uid and datediff(utime,firstday) = 1
 )
    where date_format(a.firstday,'%Y-%m') = '2021-11'
    group by a.firstday


参考大佬思路,后续还需复习

全部评论

相关推荐

02-15 15:29
青岛大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务