全部评论
select date, sum(case when pass_days=1 then 1 else 0)/count(distinct user_id) as 后1日留存率, sum(case when pass_days=2 then 1 else 0)/count(distinct user_id) as 后2日留存率, sum(case when pass_days=3 then 1 else 0)/count(distinct user_id) as 后3日留存率 from( select t1.date,t1.user_id, datediff(t2.date,t1.date) as pass_days from ( select date,user_id from log group by date,user_id ) t1 left join ( select date,user_id from log group by date,user_id ) t2 on t1.user_id=t2.user_id where t2.date>t1.date ) t3 group by date
主要是没有示例就很烦,我自己创了一个对了,但到它上面就是0😔
同求答案
同求
可以 left join 之后三天的每一天,然后 coalesce(b.user_id, c.user_id, d,user_id) as is_stay,留存就count( distinct is_stay)
相关推荐


卓越教育
| 校招
| 超多精选岗位

点赞 评论 收藏
分享
点赞 评论 收藏
分享


顺丰集团
| 校招
| 超多精选岗位
点赞 评论 收藏
分享