2022-12-30
閱讀量:
715
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;






評論(0)


暫無數據
推薦帖子
0條評論
1條評論
0條評論