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) aorder by 序号
------解决方案--------------------
- SQL code
select top 10 id=identity(int,1,1),yourcolums into #t from yourtableselect id as 排序序号,yourcolumns from #t order by id descdrop table #t