|
- select top 15 PERCENT left(编号,2) as 班级,姓名,总分,
- (select count(*)+1 from
- (select * from [14$a2:e]
- union all
- select * from [15$a2:e]
- union all
- select * from [16$a2:e]
- union all
- select * from [17$a2:e]) where left(编号,2)=left(a.编号,2)总分>a.总分) as 班级排名,
- (select count(*)+1 from
- (select * from [14$a2:e]
- union all
- select * from [15$a2:e]
- union all
- select * from [16$a2:e]
- union all
- select * from [17$a2:e]) where 总分>a.总分) as 年级排名
- from
- (select * from [14$a2:e]
- union all
- select * from [15$a2:e]
- union all
- select * from [16$a2:e]
- union all
- select * from [17$a2:e])a
- order by 总分 DESC
复制代码 不用修改数据源,直接使用SQL生成结果
PS:有兴趣可以看看我在透视表板块写的SQL简单排名系列.
一个简单的SQL排名练习:http://club.excelhome.net/thread-672307-1-1.html
SQL简单排名练习之提升:http://club.excelhome.net/thread-672460-1-1.html
sql简单排名进阶:http://club.excelhome.net/thread-673574-1-1.html |
|