日期:2014-05-18 浏览次数:20539 次
select h.IDTYPE,h.CNT,m.CNT2 from HZ h full outer join (select IDTYPE,count(*) as CNT2 from MX group by IDTYPE) on h.IDTYPE=m.IDTYPE and isnull(h.CNT,0)<>isnull(m.CNT2,0)
------解决方案--------------------
select A.IDTYPE , A.CNT, isnull(B.CNT2,0) as CNT2
from HZ A
left join
(select IDTYPE ,count(*) as CNT2
from MX
group by IDTYPE) B
on A.IDTYPE=B.IDTYPE and A.CNT<>isnull(B.CNT2,0)
------解决方案--------------------
select A.IDTYPE , A.CNT, isnull(B.CNT2,0) as CNT2
from HZ A
left join
(select IDTYPE ,count(*) as CNT2
from MX
group by IDTYPE) B
on A.IDTYPE=B.IDTYPE and A.CNT < >isnull(B.CNT2,0)