感觉观点不是很对,如果过用户是近7天内的新用户,并且在7天内不止活跃1次!用这个方法就没办法确定用户是“忠实”还是“新晋”!我觉得应该加个条件,判断用户首次活跃的时间在不在7天内,以此来确定是“忠实”还是“新晋” select user_grade,round(count(*)/(select count(distinct uid) from tb_user_log),2) as ratio from (select uid, (case when gap<7 and datediff((select max(in_time) from tb_user_log),start_time)>=7 then '忠实用户' when gap<7 and datediff((select max(in_time) from tb_user_log),start_time)<7 then '新晋用户' when gap>=7 and gap<30 then '沉睡用户' when gap>=30 then '流失用户' end) as user_grade from (select uid,datediff((select max(in_time) from tb_user_log),max(in_time)) as gap, min(date(in_time)) as start_time from tb_user_log group by uid) t1) t2 group by user_grade order by ratio desc;
4

相关推荐

10-12 19:08
666 C++
花开蝶自来_:技能:听动物叫,让雪豹闭嘴
点赞 评论 收藏
分享
牛客网
牛客企业服务