日期:2014-05-18 浏览次数:20436 次
--不分学科 select *, rank()over(order by 成绩 desc) as 名次 from tbl --分学科 select *, rank()over(partition by 课程 order by 成绩 desc) as 名次 from tbl
------解决方案--------------------
select *,名次=(select count(*) from tb where 成绩>=a.成绩) from tb a order by 成绩 desc
------解决方案--------------------
SELECT *,名次=ROW_NUMBER() OVER (ORDER BY 成绩 DESC) FROM tb ORDER BY 成绩 DESC