left join HIS_SFX b on a.JGID=b.JGID and a.SFX_BM=b.BM
left join HIS_MMS_WZZD c on c.WZBM=b.BM
left join HIS_MMS_KC_RKD d on a.JGID=d.JGID and a.DJH=d.DJH
left join HIS_KSKC_PC e on a.JGID=e.JGID and e.PKEY=a.KSKC_PC_PKEY
left join HIS_KSKC_PC e on a.JGID=e.JGID and (e.FIRST_KSKC_PC_PKEY=a.KSKC_PC_PKEY or e.PKEY=a.KSKC_PC_PKEY )
left join HIS_KSKC f on e.JGID=f.JGID and e.KSKC_PKEY=f.pkey
where a.JGID=? and f.DPTID=? and b.GLLX='W' and d.WZLZ=? and d.GYS=? and e.KYSL>0 and (b.BM like ? or b.MC like ? or EXISTS (SELECT 1 FROM HIS_SFX_ZJM z WHERE z.SFX_BM = b.BM and z.JGID=b.JGID and z.PYM like ?))