select wzdmid,wzmc00,kc000,sum(KCZSL0) from 
(select distinct b.WZDMID,b.wzmc00,a.kc000,b.kczsl0 from 
(select WZDMID,WZMC00,sum(kczsl0) kczsl0 from wz_kc0000 where  kcbmbh = 76 group by WZDMID,WZMC00 ) b,
(select a.wzdmid,(sum(DECODE(b.RCKLB0,'1',crksl0,0))-sum(DECODE(b.RCKLB0,'2',crksl0,0))) kc000
 from WZ_rck000 b,wz_rckmx0 a where a.RCKID0=b.RCKID0 AND b.ZTBZ00 in ('2','3','5')
AND (  b.qrrq00 <= '20120229' AND b.qrrq00||b.qrsj00 < '20120229'||'23:59:59'
 AND b.KFBMBH in (select KFBMBH from BM_WZKFB0))
AND b.KFBMBH = 76 
group by  a.wzdmid) a 
where a.wzdmid=b.WZDMID )
        group by wzdmid,wzmc00,kc000 having kc000<>sum(KCZSL0)

 
