/*<br>需要借助临时表。<br>以下在SQL Server中测试通过。<br>*/<br>set nocount on<br>GO<br>create table sun(reco_no int)<br>GO<br>insert into sun(reco_no)<br>select 1<br>union all<br>select 2<br>union all<br>select 3<br>union all<br>select 4<br>union all<br>select 5<br>union all<br>select 6<br>union all<br>select 7<br>union all<br>select 8<br>union all --多写一行<br>select 9<br>GO<br>select * from sun<br>GO<br><br>select identity(int, 1, 1) ID, reco_no into #t1 from sun where reco_no % 2 = 1<br>GO<br>select * from #t1<br>GO<br>select identity(int, 1, 1) ID, reco_no into #t2 from sun where reco_no % 2 = 0<br>GO<br>select * from #t2<br>GO<br>select a.reco_no, b.reco_no<br>from #t1 a full join #t2 b<br>on a.id = b.id<br>GO<br>set nocount off<br>GO<br><br>//--------------以下是结果显示<br><br>reco_no <br>----------- <br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br><br>ID reco_no <br>----------- ----------- <br>1 1<br>2 3<br>3 5<br>4 7<br>5 9<br><br>ID reco_no <br>----------- ----------- <br>1 2<br>2 4<br>3 6<br>4 8<br><br>reco_no reco_no <br>----------- ----------- <br>1 2<br>3 4<br>5 6<br>7 8<br>9 NULL