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

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

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

select
a.dt,
round(sum(case when datediff(b.dt,a.dt)=1 then 1 else 0 end)/count(distinct a.uid),2) uv_left_rate
from
(select uid,min(date(in_time)) dt 
from tb_user_log
group by uid) a
left join
(select uid,date(in_time) dt from tb_user_log
union
select uid,date(out_time) from tb_user_log) as b
on a.uid=b.uid and b.dt>a.dt
where month(a.dt)=11
group by a.dt



用sum(case when)和datediff可以算1,3,7日留存率

全部评论

相关推荐

11-06 16:50
门头沟学院 Java
用微笑面对困难:word打字比赛二等奖的我,也要来凑合凑合
点赞 评论 收藏
分享
12-14 11:43
黑龙江大学 Java
用微笑面对困难:确实比较烂,可以这么修改:加上大学的qs排名,然后大学简介要写一些,然后硕士大学加大加粗,科研经历第一句话都写上在复旦大学时,主要负责xxxx,简历左上角把学校logo写上,建议用复旦大学的简历模板
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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