高考分数线一分一段统计汇总(熟练SQL窗口函数)

65 阅读1分钟

高考分数线一分一段统计汇总(熟练SQL窗口函数)

select

总分数,

一分一段人数,

  sum(一分一段人数) over( order by 总分数 desc) as 累计排名

from(

select 

     总分数,

  count(考生号)  as 一分一段人数

from  (

       select 

            考生号,

            sum(成绩) as 总分数

       from  成绩表

       group by 考生号

    

)as 总成绩单

group  by 总分数

) as tmp