2022-12-30
閱讀量:
684
mysql 學(xué)習(xí)56--RFM均值
-- 4.3 RFM均值
select
avg(R評(píng)分) as R均值,
avg(F評(píng)分) as F均值,
avg(M評(píng)分) as M均值
from
(select
user_id,
case when timestampdiff(day,max(日期),'2014-12-19')<=6 then 5
when timestampdiff(day,max(日期),'2014-12-19')<=12 then 4
when timestampdiff(day,max(日期),'2014-12-19')<=18 then 3
when timestampdiff(day,max(日期),'2014-12-19')<=24 then 2
else 1
end as R評(píng)分,
if(count(*)=1,1,if(count(*)=2,2,if(count(*)=3,3,if(count(*)=4,4,5)))) as F評(píng)分,
if(sum(amount)<100,1,if(sum(amount)<200,2,if(sum(amount)<300,3,if(sum(amount)<400,4,5)))) as M評(píng)分
from userbehavior_new
where behavior_type='buy'
group by user_id) as t;
#3.59842.10392.2051






評(píng)論(0)


暫無(wú)數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
1條評(píng)論
0條評(píng)論