日期:2014-05-17  浏览次数:20600 次

Sql查询结果添加自动增长列如下:
select a,b,c,d from T_A 
结果如:
aa,12,32,12
dd,21,12,32
cc,32,12,32
bb,32,12,11
22,22,32,22
…………
jj,33,43,33,22
dj,32,22,33,11
有办法让结果前面增加一个自动增长列吗,结果如下:
1,aa,12,32,12
2,dd,21,12,32
3,cc,32,12,32
4,bb,32,12,11
5,22,22,32,22
………………
N,jj,33,43,33,22
N+1,dj,32,22,33,11


------解决方案--------------------
查询,
SQL code

select a,b,c,d into #t from T_A  

select * from #t

------解决方案--------------------
select ROW_NUMBER()over(order by a,b,c,d), *
from ADR
------解决方案--------------------
探讨
查询,

SQL code


select a,b,c,d into #t from T_A

select * from #t