--要有主键关联才行,不然得用临时表:
SELECT autor,id=identity(int,1,1) into #t1 from
(select autor1 as autor from insdec where autor1>0
union all
select autor2 as autor from insdec where autor2>0
union all
select autor3 as autor from insdec where autor3>0
union all
select autor4 as autor from insdec where autor4>0
union all
select autor5 as autor from insdec where autor5>0) aSELECT yall,id=identity(int,1,1) into #t2 from
(select y2 as yall from insdec where y2>0
union all
select y3 as yall from insdec where y3>0
union all
select y4 as yall from insdec where y4>0
union all
select y5 as yall from insdec where y5>0
union all
select y6 as yall from insdec where y6>0) a
select autor,yall from #t1 a full join #t2 b on a.id=b.id
SELECT autor,id=identity(int,1,1) into #t1 from
(select autor1 as autor from insdec where autor1>0
union all
select autor2 as autor from insdec where autor2>0
union all
select autor3 as autor from insdec where autor3>0
union all
select autor4 as autor from insdec where autor4>0
union all
select autor5 as autor from insdec where autor5>0) aSELECT yall,id=identity(int,1,1) into #t2 from
(select y2 as yall from insdec where y2>0
union all
select y3 as yall from insdec where y3>0
union all
select y4 as yall from insdec where y4>0
union all
select y5 as yall from insdec where y5>0
union all
select y6 as yall from insdec where y6>0) a
select autor,yall from #t1 a full join #t2 b on a.id=b.id
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货