这是我计算中位数的代码:
select distinct srt.Name,
cast(sum(sr.price) as int) as AvgCost,cast(sum(sr.cost) as int) as
AvgTransCost,cast(avg(sr.TotalTimeSpent) as int) as TotalTimeSpent,
percentile_disc(.5) WITHIN GROUP(ORDER BY avg(sr.price)) OVER(PARTITION BY srt.Name) AS MedianSpend
在这一行:
percentile_disc(.5) WITHIN GROUP(ORDER BY avg(sr.price)) OVER(PARTITION BY srt.Name) AS MedianSpend
我无法将其更改为:
(ORDER BY (sr.price))
如果我尝试在没有AVG infront(sr.price)的情况下运行代码,我会收到此错误:
http://i.stack.imgur.com/2jfS0.jpg
如何在不添加AVG,SUM,MIN,MAX之前运行它(sr.price)??