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

相关推荐

不愿透露姓名的神秘牛友
07-23 14:10
码农索隆:成年人最直白的答复:已读不回
点赞 评论 收藏
分享
写不来代码的小黑:这么小的城市能有做it的公司也不容易
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务