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

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

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

with
    a as (
        select
            distinct uid,
            date(in_time) as dt
        from
            tb_user_log
        union
        select
            distinct uid,
            date(out_time) as dt
        from
            tb_user_log
    ),
    b as (
        select
            uid,
            min(date(in_time)) as min_dt
        from
            tb_user_log
        group by
            1
    )
select
    min_dt,
    round(count(distinct a.uid) / count(distinct b.uid), 2)
from
    b
left join a on a.uid = b.uid
    and datediff(a.dt,min_dt) = 1
where min_dt >= '2021-11-01'
group by
    1
order by
    1;


全部评论

相关推荐

02-25 13:02
中南大学 C++
_追梦旅人_:大家考虑深圳睿联不,我们正在春招,可在我主页看岗位,感兴趣可直接投递~
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务