CDA持证人阿涛哥

2022-12-30   阅读量: 329

Mysql

mysql 学习47--行为转化分析(转化率=当前行为用户数/上一行为用户数)

扫码加入数据分析学习群

-- 3.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

group by behavior_type;


514.2857 3 0 关注作者 收藏

评论(0)


暂无数据

推荐课程