select a.col as 列一,b.col as 列二
from t a  inner join t b 
     on (select count(*) from t where id<a.id)
        =(select count(*) from t where id<b.id)+1

解决方案 »

  1.   

    alter table 表 add TID int default identity(1,1)
    declare @ID int 
    select @ID = max(ID) from 表
    select *,列一 as 列二 from 表 where ID > (@ID/2 - 1)
    delete from 表 where ID > (@ID/2 -1)
      

  2.   

    select NewID=IDENTITY(int,1,1),ID,Name into #TempA from TableName
    select * from
    (
    select NewID,ID,Name from #TempA
    where ID<=(select (Count(*)+1)/2 from #TempA)
    ) a
    left join
    (
    select NewID-(select (Count(*)+1)/2 from #TempA) as New ID,ID,Name from #TempA
    where ID>(select (Count(*)+1)/2 from #TempA)
    ) b on a.NewID=b.NewID
      

  3.   

    select a.col as 列一,b.col as 列二
    from t a  left join t b 
         on (select count(*) from t where id<a.id)
            =(select count(*) from t where id<b.id)+1
      

  4.   

    楼上小李大师的有些不对,少了东西,正确的是
    select b.id as 列二,a.id as 列一
    from t a  inner join t b 
         on (select count(*) from t where id<a.id)-1
            =(select count(*) from t where id<b.id)+1
      

  5.   

    上面那个写的有点粗心,这个我自己已经试过了是可行的select NewID=IDENTITY(int,1,1),ID,Name into #TempA from TableName
    select a.ID,a.Name,b.ID,b.Name from
    (
    select NewID,ID,Name from #TempA
    where NewID<=(select (Count(*)+1)/2 from #TempA)
    ) a
    left join
    (
    select NewID-(select (Count(*)+1)/2 from #TempA) as NewID,ID,Name from #TempA
    where NewID>(select (Count(*)+1)/2 from #TempA)
    ) b on a.NewID=b.NewID
    Drop Table #TempA
      

  6.   

    成大师了???  select a.col as 列一,b.col as 列二
    from t a  left join t b 
         on (select count(*) from t where id<=a.id)   --这里应<=
            =(select count(*) from t where id<=b.id)+1  --这里应<=