利用sql的row_number() over()函数
select * from (
select ROW_NUMBER() OVER(partition by CourseName ORDER BY Score desc) AS rownum,* from MyTest
) as a
where rownum < 4
order by CourseName
分析:over(partition by CourseName order by Score desc) 按照sroce排序进行累计,partition by是按照CourseName 分区。
分类统计:case when..then..else..end
https://blog.csdn.net/gc1329689056/article/details/91878723