热线电话:13121318867

登录
2022-12-30 阅读量: 507
mysql 学习48--浏览—加购—购买的转化率

-- 3.2.1 浏览—加购—购买的转化率

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','cart','buy')

group by behavior_type;


0.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子