select 用户分级, round(count(uid)/(select count(distinct uid) from tb_user_log),2) as 比例 from ( select uid, case when early_dt >= date_sub(today,interval 6 day) then '新晋用户' when latest_dt >= date_sub(today,interval 6 day) then '忠实用户' when latest_dt >= date_sub(today,interval 29 day) and latest_dt < date_sub(today,interval 6 day) then '沉睡用户' when latest_dt < date_sub(today,interval 29 day) then '流失用户' end) '用户分级' from ( select uid,max(date(out_time)) latest_dt,min(date(in_time)) early_dt from tb_user_log group by uid ) t1 ) t2 group by 用户分级 order by 比例 desc
1

相关推荐

03-14 16:04
已编辑
安徽农业大学 算法工程师
痴心的她allin秋...:啥笔试都挂怎么办,某9本考研下岸,练也没时间了,对算法也不感兴趣,大部分大厂笔试只能A0-1个😄
米哈游笔试
点赞 评论 收藏
分享
SHC2:春招先狠狠投递,然后你看看能不能申请香港新加坡的一年制master,花不了多少钱,或者现在赶紧去刷一段实习。HR专业考研没必要
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务