2022-12-30
阅读量:
605
mysql 学习49--浏览—收藏---加购—购买的转化率
-- 3.2.2 浏览—收藏-加购—购买的转化率
select
behavior_type,
count(distinct user_id) as 用户数,
lag(count(distinct user_id),1) over(order by if(behavior_type='pv',1,if(behavior_type='fav',2,if(behavior_type='cart',3,4)))) as 上一行为用户数,
ifnull(count(distinct user_id)/lag(count(distinct user_id),1) over(order by if(behavior_type='pv',1,if(behavior_type='fav',2,if(behavior_type='cart',3,4)))),1) as 转化率
from UserBehavior_new
where behavior_type in ('pv','fav','cart','buy')
group by behavior_type;
##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0.0000
1
0
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
1条评论