表格如下:
num 
1
2
3
4
...
希望得到下面的结果:
1 2
3 4
.. ..
每2条记录横向排列

解决方案 »

  1.   

    create table test(num nvarchar(10))
    insert into test 
    select '1'
    union all select '2'
    union all select '3'
    union all select '4'
    union all select '5'
    union all select '6'select id=identity(int,1,1),num=num into #t from testselect id=identity(int,1,1),num=num into #t1 from #t where id%2=1
    select id=identity(int,1,1),num=num into #t2 from #t where id%2=0
    select num1=#t1.num,num2=#t2.num from #t1,#t2 where #t1.id=#t2.id
    drop table #t
    drop table #t1
    drop table #t2
    drop table test
      

  2.   

    1
    2
    3
    4
    ..
    ..
    num是递增的