取分组前n //根据课程分组,查询学生成绩前2名 select * from (select *,row_number() over (partition by course order by score) as ranking from student) t where t.ranking<=2