假设你的纪录集为“select top 10 * from ... as AAA or der bai Key”
那么有一种方法可以排名:
select
NUM=1+(select count(Key) from
(select top 10 * from ... order by Key) as BBB where BBB.key<AAA.key)
,*
from (select top 10 * from ... order by Key) as AAA
select *,identity(int,1,1) as rank into #t from 表 order by 排名字段 desc
select * from #t
无法得到正确的顺序,会出现2,1,3这样的情况
============================================================================
改一下:
select identity(int,1,1) as rank, * into #t from 表 order by 排名字段 desc
select * from #t
drop table #t
假设你的纪录集为“select top 10 * from ... as AAA or der bai Key”
那么有一种方法可以排名:
select
NUM=1+(select count(Key) from
(select top 10 * from ... order by Key) as BBB where BBB.key<AAA.key)
,*
from (select top 10 * from ... order by Key) as AAA