1.根据 a.language_id=b.id 将两个表连接;
2.运用窗口函数 language_id 分组,组内 score 进行倒序排序,需要用的排序函数是 dense_rank;
3.将组内排序好的表作为 from 表,筛选出需要用的 id,name,score 字段,过滤条件是 ranking<3
4.对结果进行 name 升序,score 降序,id 升序
select c.id,c.name,c.score from
(select a.id,b.name,a.score,dense_rank() over(partition by a.language_id order by a.score desc) as ranking
from grade a
inner join language b
on a.language_id=b.id) c
where c.ranking<3
order by c.name asc,c.score desc, c.id asc