这样对吗 select login_dt ,count(case when datediff(next_day,login_dt)=1 then 1 else null)/count(distinct user_id) as next_rate ,count(case when datediff(next_day,login_dt)=2 then 1 else null)/count(distinct user_id) as 3_rate FROM( select user_id ,login_dt ,lead(login_dt,1,'9999-12-31')over(partition by user_id order by login_dt) as next_day ,lead(login_dt,2,'9999-12-31')over(partition by user_id order by login_dt) as 3_day ,row_number()over(partition by user_id order by login_dt) as rn from ( select distinct user_id ,cast(login_dt as date) as login_dt from ods_usr_login_log ) as t1 where rn = 1 ) t2 group by login_dt ;
点赞 1

相关推荐

点赞 评论 收藏
分享
牛客网
牛客企业服务