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

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

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

with a as(
    #首次登陆日期
select 
    uid,
    date(min(in_time)) as date
from tb_user_log
group by uid
),
b as(
    #全部活跃日期
select uid,
       date(in_time) as date
from tb_user_log
union
select uid,
       date(out_time) as date
from tb_user_log
order by uid 
),
c as(
select a.uid as uid,
    a.date as first_date,
    b.date as date
from a
left join b on a.uid=b.uid
    and a.date=date_sub(b.date,interval 1 day)
)
select 
    first_date as dt,
    round(count(date)/count(first_date),2) as uv_left_rate
from c
where month(first_date)=11
group by first_date
order by dt
;





全部评论

相关推荐

我要娶个什么名:学长你电脑闹鬼了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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