题解 | #SQL74 考试分数(三) #
考试分数(三)
http://www.nowcoder.com/practice/b83f8b0e7e934d95a56c24f047260d91
select t.id, t.name, t.score from (select g.id, l.name, g.score, dense_rank() over(partition by language_id order by score desc) as rank_1 from grade g left join language l on l.id = g.language_id ) t where t.rank_1 in (1, 2) order by t.name asc, t.score desc
先分类重复排序,将组内排名标出来。
后将排名1、2的拎出来。
后按 name、 grade 排序。