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

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

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

-- 分级 活跃间隔 各活跃等级用户占比 
with t1 as (select count(distinct case when datediff(current_time1,max_time) <= 6 and datediff(current_time1,min_time) > 6 then uid else null end) zhongshi_label,
count(distinct case when datediff(current_time1,max_time) <=6 and datediff(current_time1,min_time) <= 6 then uid else null end) xinji_label,
count(distinct case when datediff(current_time1,max_time) >6 and datediff(current_time1,min_time) > 6 then uid else null end) chenshui_label,
count(distinct case when datediff(current_time1,max_time) >29 and datediff(current_time1,min_time) > 29 then uid else null end) liushi_label
from (select uid,
max(in_time) over () current_time1,
min(in_time) over (partition by uid) min_time,
max(in_time) over (partition by uid) max_time,
in_time,out_time
from tb_user_log) t0)

select '忠实用户' user_grade,round(zhongshi_label/(zhongshi_label+xinji_label+chenshui_label),2) ratio from t1
union all 
select '新晋用户' user_grade,round(xinji_label/(zhongshi_label+xinji_label+chenshui_label),2) ratio from t1
union all 
select '沉睡用户' user_grade,round((chenshui_label - liushi_label)/(zhongshi_label+xinji_label+chenshui_label),2) ratio from t1
union all 
select '流失用户' user_grade,round(liushi_label/(zhongshi_label+xinji_label+chenshui_label),2) ratio from t1

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-21 19:05
面试官_我太想进步了:混学生会的,难怪简历这么水
点赞 评论 收藏
分享
一个菜鸡罢了:哥们,感觉你的简历还是有点问题的,我提几点建议,看看能不能提供一点帮助 1. ”新余学院“别加粗,课程不清楚是否有必要写,感觉版面不如拿来写一下做过的事情,教育经历是你的弱势就尽量少写 2. “干部及社团经历”和“自我评价”删掉 3. 论文后面的“录用”和“小修”啥的都删掉,默认全录用,问了再说,反正小修毕业前肯定能发出来 4. 工作经验和研究成果没有体现你的个人贡献,着重包装一下个人贡献
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务