我有一个县的表格,其中包含该县所有学校的测试统计数据。我试图展示排名前10的学校,其中写作和阅读分数之间的差异是最大的
select *
from
(select SchoolName, WriPassingPer, ReaPassingPer,
(WriPassingPer - WriPassingPer) as Difference, dense_rank() over
(order by ABS(WriPassingPer - WriPassingPer) desc) as rnk from Pima)
where rnk <= 10;
我希望它看起来像
Rank | School Name | Writing Score | Reading Score | Difference
但目前它只列出该县的每所学校,排名为1或2.该县有283所学校
答案 0 :(得分:2)
您正在计算WriPassingPer - WriPassingPer
而不是WriPassingPer - ReaPassingPer
或类似的东西......