当前位置: 代码迷 >> Sql Server >> sqlserver2000 top语句如何添加排序序号
  详细解决方案

sqlserver2000 top语句如何添加排序序号

热度:390   发布时间:2016-04-27 12:24:41.0
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) 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
  相关解决方案