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 排序。