利用sql的row_number() over()函数

查询各科的前3名的同学信息:Sql分组排序 与 分类统计

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

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-12-05
  • 2022-01-01
  • 2022-01-26
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2021-04-02
  • 2022-12-23
  • 2022-02-10
  • 2022-01-11
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案