2022-12-30
閱讀量:
783
mysql 學習52--產(chǎn)品貢獻定量分析(帕累托分析)
-- 3.3 產(chǎn)品貢獻定量分析(帕累托分析)
##累積銷售額占比=累積銷售額/總銷售額
select *
from
(select
item_category,
sum(amount) as 銷售額,
sum(sum(amount)) over(order by sum(amount) desc) as 累積銷售額,
#當over中指定了排序,但是沒有指定分區(qū)和指定滑動窗口范圍時,默認計算當前分區(qū)內(nèi)第一行到當前行(排序字段)取值范圍內(nèi)的記錄
sum(sum(amount)) over() as 總銷售額,
#當over中沒有指定分區(qū)、排序和滑動窗口范圍時,表中所有記錄為一個區(qū),默認計算當前分區(qū)內(nèi)的所有記錄
sum(sum(amount)) over(order by sum(amount) desc)/sum(sum(amount)) over() as 累積銷售額占比
from userbehavior_new
where behavior_type='buy'
group by item_category) as t
where 累積銷售額占比<=0.8;






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
1條評論
0條評論