日期:2014-05-18 浏览次数:20577 次
select (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t1.1 end) a1, (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t1.2 end) a2, (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t1.3 end) a3, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t1.甲 end) a甲, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t1.乙 end) a乙, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t1.丙 end) a丙, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t1.a end) aa, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t1.b end) ab, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t1.c end) ac, NO, (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t2.1 end) b1, (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t2.2 end) b2, (case when t1.1=t2.1 and t1.2=t2.2 and t1.3=t2.3 then ' ' else t2.3 end) b3, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t2.甲 end) b甲, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t2.乙 end) b乙, (case when t1.甲=t2.甲 and t1.乙=t2.乙 and t1.丙=t2.丙 then ' ' else t2.丙 end) b丙, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t2.a end) ba, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t2.b end) bb, (case when t1.a=t2.a and t1.b=t2.b and t1.c=t2.c then ' ' else t2.c end) bc from a as t1 inner join b as t2 on t2.no=t1.no
------解决方案--------------------
select isnull(aa.no,isnull(bb.no,cc.no)) no,col1,col2,col3,甲,乙 ,丙,a,b,c from
(select a.no,b.col1,b.col2,b.col3 from a join b on a.no=b.no and a.col1+a.col2+a.col3<>b.col1+b.col2+b.col3) aa full outer join
(select A.甲 , A.乙 , A.丙,a.no from a join b on a.no=b.no and A.甲 + A.乙 + A.丙<>b.甲 + b.乙 + b.丙) bb on aa.no=bb.no full outer join
(select A.a , A.b , a.c,a.no from a join b on a.no=b.no and A.a + A.b + A.c<>b.a + b.b + b.c) cc on bb.no=cc.no
------解决方案--------------------
select isnull(aa.no,isnull(bb.no,cc.no)) no,col1,col2,col3,甲,乙 ,丙,a,b,c from (select a.no,b.col1,b.col2,b.col3 from a join b on a.no=b.no and a.col1+a.col2+a.col3<>b.col1+b.col2+b.col3) aa full outer join (select A.甲 , A.乙 , A.丙,a.no from a join b on a.no=b.no and A.甲 + A.乙 + A.丙<>b.甲 + b.乙 + b.丙) bb on aa.no=bb.no full outer join (select A.a , A.b , a.c,a.no from a join b on a.no=b.no and A.a + A.b + A.c&l