标签:
name class score select name,class,score,rank() over (partition by class order by score desc) rank1,row_number over(partition by class order by score desc) rank2 from test
Jack 2 98 --以class分组,以score进行排序
rose 1 97
Jason 1 98
Lucy 1 99
Johnny 2 96
Tom 1 98
name | class | score | rank1 | rank2 |
Lucy | 1 | 99 | 1 | 1 |
jason | 1 | 98 | 2 | 2 |
tom | 1 | 98 | 2 | 3 |
rose | 1 | 97 | 4 | 4 |
jack | 2 | 98 | 1 | 1 |
johnny | 2 | 96 | 2 | 2 |
标签:
原文地址:http://www.cnblogs.com/huangxy583040305/p/4648570.html