另一个帖的答案
create table test 
(IDno int identity(1,1) not null,
 XSName varchar(20),
 XPQTY int)insert test(XSName,XPQTY) 
          select '李全',67
union all select '付丽',457
union all select '陈林',379
union all select '李军',96
union all select '尹苏',877
union all select '徐华',788
go--/*
Select Identity(int,1,1) as 名次,xsname,xpqty Into #temptable From test order by xpqty desc
Select * From #temptable 
Drop Table #temptable
--*/select * from test order by XPQTY descselect *,1+(select count(*) from test where XPQTY>a.XPQTY) as 名次
from test a
order by XPQTY descdrop table test