经过查询后
形成:

解决方案 »

  1.   

    select * from 
    (select row_number() over(order by getdate()) no,aa from tb) a
    full join 
    (select row_number() over(order by getdate()) no,bb from tb) b on a.no=b.no
    full join
    (select row_number() over(order by getdate()) no,aa from tb) c on a.no=c.no
      

  2.   


    select aa,id=indentity(1,1) into tb1 from tb where aa<>''
    select bb,id=indentity(1,1) into tb2 from tb where bb<>''
    select cc,id=indentity(1,1) into tb3 from tb where cc<>''
    select aa,bb,cc 
    from tb1 a 
    full outer join tb2 b 
    on a.id=b.id
    full outer join tb3 c 2
    on b.id=c.id
    drop table tb1,tb2,tb3
      

  3.   

    不论版本,思路都一样,把不为0的那列增加个自增列字段,然后3组LEFT JOIN或者RIGHT JOIN即可。
      

  4.   

    select  identity(int,1,1) as id , aa into #tb1 from t2 where aa<>''
    select  identity(int,1,1) as id , bb into #tb2 from t2 where bb<>''
    select  identity(int,1,1) as id , cc into #tb3 from t2 where cc<>''select * from #tb1 a full join #tb2 b on a.id =b.id full join #tb3 on a.id= c.id