答案 0 :(得分:2)
假设您希望每个州的“最高”平均值成为排序的定义特征。
我们可以通过构建一个运行GROUP BY
的CTE或子查询来实现这一点,并在尝试查找前10个之前聚合以将每个状态减少为一行:
;With Highest as (
select [Provider State],MAX([Average Medicare Payments]) as Medicare
from [Medicare_InPatient_2014]
group by [Provider State]
)
select top 10 *
from Highest
order by Medicare desc