SELECT g.id,l.name,g.score FROM (SELECT id,language_id,score, DENSE_RANK() OVER(PARTITION BY language_id ORDER BY score DESC) AS rk FROM grade) g LEFT JOIN language l ON l.id = g.language_id WHERE g.rk <= 2 ORDER BY l.name,g.score DESC,g.id开个窗口函数 DENSE_RANK 1,1,1,2 排名