有如下数据表
求每门课程成绩的前两名
通过窗口函数实现
select 课程号,学号,成绩
from (
select *,row_number() over (PARTITION by 课程号 order by 成绩 desc) as ranking
from score) as a
where ranking <=2;
求每门课程成绩的前两名
通过窗口函数实现
select 课程号,学号,成绩
from (
select *,row_number() over (PARTITION by 课程号 order by 成绩 desc) as ranking
from score) as a
where ranking <=2;