日期:2014-05-18  浏览次数:20465 次

sqlserver2000 top语句怎么添加排序序号
sqlserver2000 top语句怎么添加排序序号 我想取前十条 同时按照降序排列并加上序号

------解决方案--------------------
SQL code
select *,
  序号=(select count(1) from (select top 10 * from tb order by id) b where b.id>=a.id)
from
(select top 10 * from tb order by id) a
order by 序号

------解决方案--------------------
SQL code

select top 10 id=identity(int,1,1),yourcolums into #t from yourtable
select id as 排序序号,yourcolumns from #t order by id desc
drop table #t