记得原来用FOXPRO的时候,为了进行排名要专门写一个过程,很复杂,还要考虑并列名次,现在只要一条SQL语句就可以搞定:
        /*排名语句

         ---全县排名
         select 姓名,总分, (select count(*)+1 from 成绩 where a.总分>成绩.总分) as 名次 from 成绩 a


         ---分校排名
         select 校名,姓名,总分, (select count(*)+1 from 成绩 where 成绩.总分>a.总分 and 成绩.校名=a.校名) as 名次 from 成绩 a where 校名='XXXX学校' order by 校名,名次

         ---几个学校组合排名
         select 校名,姓名,总分, (select count(*)+1 from 成绩 where 成绩.总分>a.总分) as 名次 from 成绩 a where 校名 in ('XX1学校','XX2学校')  order by 名次
*/


        

相关文章:

  • 2022-12-23
  • 2021-08-18
  • 2022-03-07
  • 2021-11-01
  • 2021-08-26
  • 2021-06-17
  • 2021-05-18
猜你喜欢
  • 2021-05-28
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案