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

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

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

with t1 as
(select 
    uid,
    date(in_time) as dt,
    date(min(in_time) over(partition by uid)) as mindt
from tb_user_log
union 
select 
    uid,
    date(out_time) as dt,
    date(min(in_time) over(partition by uid)) as mindt
from tb_user_log
)
select 
    mindt,
    round(sum(dif)/count(distinct uid),2) as uv_left_rate
from (
select 
    uid,
    dt,
    mindt,
    if(mindt=date_sub(dt, interval 1 day), 1, 0) as dif
from t1  
)t2
where date_format(mindt, '%Y%m') = 202111
group by mindt









全部评论

相关推荐

11-12 14:30
已编辑
广东科技学院 前端工程师
迷茫的小刺猬在迎接o...:前端岗位越来越少了,中小厂也更倾向全栈了,更不需要初级或者实习。可能就大厂才会有一些岗位,但是很看学历。
实习,投递多份简历没人回...
点赞 评论 收藏
分享
10-22 19:44
门头沟学院 Java
面了100年面试不知...:那我得去剪个头
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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