create or replace view vw_sf_mzghks
(bmbh00, bh0000, flag00, bmmc00, pysm00, wbsm00, bmxz00, czbz00, ksghdy)
as
select
    A.BMBH00    ,    --????
    A.BH0000    ,    --??????,?????
    A.FLAG00        ,            --???'1'--??,'0'--??
    A.BMMC00    ,    --????
    A.PYSM00    ,        --????
    A.WBSM00    ,    --????
    A.BMXZ00    ,    --????
    A.CZBZ00    ,    --'0'????,???,
    (select decode(sign(count(1)),1,1,0) from BM_KSGHDY b where b.bmbh00=a.bmbh00)
from  BM_BMBM00 A  where  FLAG00 = '1' and CZBZ00 <> '2' AND SFQTXS='Y' and (bmmc00 not like '%(中)%')
 and (bmmc00 not like '%(停用)%')
 and (bmmc00 not like '%分院%')
 and  (bmbh00 not in ( '38','56','67','75','79','333','334','336','340','341','342','343',
'344','345','346','347','349','350','351','352','353','357','358','359','396'));
