我想创建一个图表来代表一些商店的表现。x 轴将代表商店的总收入超过所有商店的平均收入。
y 轴将表示特定商店的客户访问该商店的平均频率超过所有客户访问所有商店的平均频率。
这是我尝试过的:
select
distinct [Order].shop_id
, SUM(total) /((select AVG(o.shopTotal)
from
(
select
distinct shop_id , SUM(total) as shopTotal
from [Order]
group by shop_id
)o)*0.1) as revPerAvgRev
,COUNT(distinct orderno) /((select AVG(orders)
from
(
select
distinct shop_id , room, COUNT(distinct orderno) as orders
from [Order]
group by shop_id , room
)o)*0.1) as freqPerAvgFreq
from [Order]
group by [order].shop_id
order by revPerAvgRev desc
select distinct shop_id ,room , count(distinct orderno)
from [Order]
group by shop_id , room
我相信顾客光顾商店的平均频率是可以的。但我无法正确计算每位顾客光顾商店的平均频率。
注意:每位顾客只光顾一家商店。