请教这个SQL怎么写?
create   table   test 
 ( 
    提出银行行号   varchar(10), 
    提入银行行号   varchar(10), 
    笔数   int 
 ) 
 insert   into   test   select    '120 ', '050 ',1 
 union   all   select    '120 ', '051 ',2 
 union   all   select    '120 ', '052 ',3 
 union   all   select    '120 ', '053 ',4 
 /* 
 说明:提出行号和提入行号是指银行的编号,笔数是指票据的数量   
                   就是说:从编号为120的银行提出的票据分别存入了编号为050,051,052,053的银行中   
                                           存入的票据数量分别是1,2,3,4 
 */   
 --要得到以下报表 
 /* 
 提入行行号                  笔数                        提入行行号                     笔数                              提出行行号                                                                                          
 050                                       1                                    052                                       3                                          120                                                                                                         
 051                                       2                                    053                                       4                                          120 
 */ 
 drop   table   test
------解决方案----------------------排序可能不同,不知道是否能接受   
 declare @test table 
 ( 
  提出银行行号 varchar(10), 
  提入银行行号 varchar(10), 
  笔数 int 
 ) 
 insert into @test select  '120 ', '050 ',1 
 union all select  '120 ', '051 ',2 
 union all select  '120 ', '052 ',3 
 union all select  '120 ', '053 ',4 
 union all select  '121 ', '053 ',1 
 union all select  '121 ', '051 ',2 
 union all select  '121 ', '054 ',5 
 union all select  '122 ', '053 ',6   
 select  
 a.提入银行行号,a.笔数,b.提入银行行号,b.笔数,a.提出银行行号 
 from @test a  
 left join @test b 
 on a.提出银行行号=b.提出银行行号 
 and (select count(distinct 提入银行行号) from @test where 提出银行行号=b.提出银行行号 and 提入银行行号 <=b.提入银行行号 and 提入银行行号> a.提入银行行号) =1 
 where (select count(distinct 提入银行行号) from @test where 提出银行行号=a.提出银行行号 and 提入银行行号 <=a.提入银行行号) % 2 =1   
 --结果 
 提入银行行号     笔数          提入银行行号     笔数          提出银行行号      
 ---------- ----------- ---------- ----------- ----------  
 050        1           051        2           120 
 052        3           053        4           120 
 051        2           053        1           121 
 054        5           NULL       NUL