题解 | #统计活跃间隔对用户分级结果#

统计活跃间隔对用户分级结果

http://www.nowcoder.com/practice/6765b4a4f260455bae513a60b6eed0af

select n1, round(n2/ t1, 2) as ratio from ( select case when timestampdiff(day, date(t1.d1), '2021-11-04') <= 6 then '新晋用户' when timestampdiff(day, date(t2.d1), '2021-11-04') >= 29 then '流失用户' when timestampdiff(day, date(t1.d1), '2021-11-04') > 6 and timestampdiff(day, date(t2.d1), '2021-11-04') <= 6 then '忠实用户' else '沉睡用户' end as n1, count(*) as n2 from (select uid, min(date(in_time)) as d1 from tb_user_log group by uid)t1 left join (select uid, max(date(in_time)) as d1 from tb_user_log group by uid)t2 using (uid) group by n1 )t3 left join ( select count(distinct uid) as t1 from tb_user_log )t4 on 1 order by ratio desc

全部评论

相关推荐

双非一本失业第二年:《机器视觉垃圾分类》
点赞 评论 收藏
分享
11-14 16:13
已编辑
重庆科技大学 测试工程师
Amazarashi66:不进帖子我都知道🐮❤️网什么含金量
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务