select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.fyzl,a.jjks order by a.jjks,sfx.fyzl
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.KJZFL,a.jjks order by a.jjks,sfx.KJZFL
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.HSZFL,a.jjks order by a.jjks,sfx.HSZFL
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.BASYFL,a.jjks order by a.jjks,sfx.BASYFL
select sum(d.SFXSJZFY) fy,d.fydl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by d.fydl,a.jjks order by a.jjks,d.fydl
select count(*) rc,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID where a.JGID=? and (a.JZLX='M' or a.JZLX='J' ) and a.jjks like ? and c.SFZT = 1 and c.SFRQ >=? and c.SFRQ <= ? group by a.jjks order by a.jjks
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.fyzl,a.jjks,a.jjys order by a.jjks,a.jjys,sfx.fyzl
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.KJZFL,a.jjks,a.jjys order by a.jjks,a.jjys,sfx.KJZFL
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.HSZFL,a.jjks,a.jjys order by a.jjks,a.jjys,sfx.HSZFL
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.BASYFL,a.jjks,a.jjys order by a.jjks,a.jjys,sfx.BASYFL
select sum(d.SFXSJZFY) fy,d.fydl fylb,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by d.fydl,a.jjks,a.jjys order by a.jjks,a.jjys,d.fydl
select sum(d.SFXSJZFY) ypfy,a.jjks,a.jjys from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX e on d.SFX=e.bm and d.JGID=e.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and c.SFZT =1 and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and b.JSZT =1 and e.gllx='Y' group by a.jjks,a.jjys order by a.jjks,a.jjys
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.fyzl,a.jjks order by a.jjks,sfx.fyzl
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.KJZFL,a.jjks order by a.jjks,sfx.KJZFL
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.HSZFL,a.jjks order by a.jjks,sfx.HSZFL
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.BASYFL,a.jjks order by a.jjks,sfx.BASYFL
select sum(d.SFXSJZFY) fy,d.fydl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by d.fydl,a.jjks order by a.jjks,d.fydl
select sum(d.SFXSJZFY) ypfy,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX e on d.SFX=e.bm and d.JGID=e.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and c.SFZT =1 and a.jjks like ? and c.SFRQ >=? and c.SFRQ <= ? and b.JSZT =1 and e.gllx='Y' group by a.jjks order by a.jjks
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,e.YZZXKS jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(e.YZZXKS,'%') like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.fyzl,e.YZZXKS order by e.YZZXKS,sfx.fyzl
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,e.YZZXKS jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(e.YZZXKS,'%') like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.KJZFL,e.YZZXKS order by e.YZZXKS,sfx.KJZFL
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,e.YZZXKS jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(e.YZZXKS,'%') like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.HSZFL,e.YZZXKS order by e.YZZXKS,sfx.HSZFL
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,e.YZZXKS jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(e.YZZXKS,'%') like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by sfx.BASYFL,e.YZZXKS order by e.YZZXKS,sfx.BASYFL
select sum(d.SFXSJZFY) fy,d.fydl fylb,e.YZZXKS jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(e.YZZXKS,'%') like ? and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by d.fydl,e.YZZXKS order by e.YZZXKS,d.fydl
select sum(fy) fy,fylb,jjks,JZLX,hzpkey,pkey,jzno from (
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.fyzl,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
union all
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.fyzl,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
select sum(fy) fy,fylb,jjks,JZLX,hzpkey,pkey,jzno from (
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.KJZFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
union all
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.KJZFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
select sum(fy) fy,fylb,jjks,JZLX,hzpkey,pkey,jzno from (
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and c.PJZT = 1 and a.jjks like ? #select# and c.sfRQ > ? and c.sfRQ <= ? group by sfx.HSZFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
union all
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and c.CHPKEY is not null and c.SFZT != 0 and a.jjks like ? #select# and c.sfRQ > ? and c.sfRQ <= ? group by sfx.HSZFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
select sum(fy) fy,fylb,jjks,JZLX,hzpkey,pkey,jzno from (
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.BASYFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
union all
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.BASYFL,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno
select sum(d.SFXSJZFY) fy,d.fydl fylb,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 group by d.fydl,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno order by a.jjks,a.jzno,a.pkey,a.hzpkey,d.fydl
select sum(d.SFXSJZFY) ypfy,a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_SFX e on d.SFX=e.bm and d.JGID=e.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and a.jjks like ? #select# and c.SFRQ >=? and c.SFRQ <= ? and c.SFZT =1 and b.JSZT =1 and e.gllx='Y' group by a.jjks,a.JZLX,a.hzpkey,a.pkey,a.jzno order by a.jjks,a.jzno,a.pkey,a.hzpkey
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.fyzl,a.jjks
union all
select sum(d.SFXSJZFY) fy,sfx.fyzl fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.fyzl,a.jjks
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.KJZFL,a.jjks
union all
select sum(d.SFXSJZFY) fy,sfx.KJZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.KJZFL,a.jjks
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.HSZFL,a.jjks
union all
select sum(d.SFXSJZFY) fy,sfx.HSZFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.HSZFL,a.jjks
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.PJZT = 1 group by sfx.BASYFL,a.jjks
union all
select sum(d.SFXSJZFY) fy,sfx.BASYFL fylb,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by sfx.BASYFL,a.jjks
select count(*) rc,jjks from (select distinct a.pkey,a.jjks from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID where a.JGID=? and nvl(a.jjks,'%') like ? and a.jzlx='M' and c.PJZT=? and c.sfrq > ? and c.sfrq <=? ) group by jjks order by jjks
left join HIS_SFZD_ZB b on a.GLZDBPKEY=b.pkey and a.JGID=b.JGID
left join HIS_YB_DJ c on b.pkey=c.ZDZBPKEY and b.JGID=c.JGID
left join HIS_YB_JSB j on c.JGID=j.JGID and c.IPT_NO=j.IPT_NO and c.MDTRT_ID=j.MDTRT_ID
left join HIS_YB_SCMX d on d.MDTRT_ID=j.MDTRT_ID and d.JGID=j.JGID and d.SETL_ID=j.SETL_ID
left join HIS_JZ_BASEINFO e on b.jzpkey=e.pkey and b.JGID=e.JGID
left join HIS_SFX sfx on d.MEDINS_LIST_CODG=sfx.bm and d.JGID=sfx.JGID
where a.JGID=? and nvl(e.jjks,'%') like ? and e.jzlx='M' and a.PJLX='MS' and a.SFZT !='0' and c.djcxzt='0' and j.CXZT='0' and c.MDTRT_ID is not null and a.sfrq >=? and a.sfrq <=?
left join HIS_SFZD_ZB b on a.GLZDBPKEY=b.pkey and a.JGID=b.JGID
left join HIS_YB_DJ c on b.pkey=c.ZDZBPKEY and b.JGID=c.JGID
left join HIS_YB_JSB j on c.JGID=j.JGID and c.IPT_NO=j.IPT_NO and c.MDTRT_ID=j.MDTRT_ID
left join HIS_YB_SCMX d on d.MDTRT_ID=j.MDTRT_ID and d.JGID=j.JGID and d.SETL_ID=j.SETL_ID
left join HIS_JZ_BASEINFO e on b.jzpkey=e.pkey and b.JGID=e.JGID
left join HIS_SFX sfx on d.MEDINS_LIST_CODG=sfx.bm and d.JGID=sfx.JGID
where a.JGID=? and nvl(e.jjks,'%') like ? and e.jzlx='M' and a.PJLX='MS' and a.SFZT !='0' and c.djcxzt='0' and j.CXZT='0' and c.MDTRT_ID is not null and a.sfrq >=? and a.sfrq <=?
group by sfx.KJZFL,e.jjks order by e.jjks,sfx.KJZFL
left join HIS_SFZD_ZB b on a.GLZDBPKEY=b.pkey and a.JGID=b.JGID
left join HIS_YB_DJ c on b.pkey=c.ZDZBPKEY and b.JGID=c.JGID
left join HIS_YB_JSB j on c.JGID=j.JGID and c.IPT_NO=j.IPT_NO and c.MDTRT_ID=j.MDTRT_ID
left join HIS_YB_SCMX d on d.MDTRT_ID=j.MDTRT_ID and d.JGID=j.JGID and d.SETL_ID=j.SETL_ID
left join HIS_JZ_BASEINFO e on b.jzpkey=e.pkey and b.JGID=e.JGID
left join HIS_SFX sfx on d.MEDINS_LIST_CODG=sfx.bm and d.JGID=sfx.JGID
where a.JGID=? and nvl(e.jjks,'%') like ? and e.jzlx='M' and a.PJLX='MS' and a.SFZT !='0' and c.djcxzt='0' and j.CXZT='0' and c.MDTRT_ID is not null and a.sfrq >=? and a.sfrq <=?
group by sfx.HSZFL,e.jjks order by e.jjks,sfx.HSZFL
left join HIS_SFZD_ZB b on a.GLZDBPKEY=b.pkey and a.JGID=b.JGID
left join HIS_YB_DJ c on b.pkey=c.ZDZBPKEY and b.JGID=c.JGID
left join HIS_YB_JSB j on c.JGID=j.JGID and c.IPT_NO=j.IPT_NO and c.MDTRT_ID=j.MDTRT_ID
left join HIS_YB_SCMX d on d.MDTRT_ID=j.MDTRT_ID and d.JGID=j.JGID and d.SETL_ID=j.SETL_ID
left join HIS_JZ_BASEINFO e on b.jzpkey=e.pkey and b.JGID=e.JGID
left join HIS_SFX sfx on d.MEDINS_LIST_CODG=sfx.bm and d.JGID=sfx.JGID
where a.JGID=? and nvl(e.jjks,'%') like ? and e.jzlx='M' and a.PJLX='MS' and a.SFZT !='0' and c.djcxzt='0' and j.CXZT='0' and c.MDTRT_ID is not null and a.sfrq >=? and a.sfrq <=?
group by sfx.BASYFL,e.jjks order by e.jjks,sfx.BASYFL
left join HIS_SFZD_ZB b on a.GLZDBPKEY=b.pkey and a.JGID=b.JGID
left join HIS_YB_DJ c on b.pkey=c.ZDZBPKEY and b.JGID=c.JGID
left join HIS_YB_JSB j on c.JGID=j.JGID and c.IPT_NO=j.IPT_NO and c.MDTRT_ID=j.MDTRT_ID
left join HIS_JZ_BASEINFO e on b.jzpkey=e.pkey and b.JGID=e.JGID
where a.JGID=? and nvl(e.jjks,'%') like ? and e.jzlx='M' and a.PJLX='MS' and a.SFZT !='0' and c.djcxzt='0' and j.CXZT='0' and a.sfrq >=? and a.sfrq <=?
select sum(d.SFXSJZFY) fy,a.jjks,a.jjys,jgzdb.value4 from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID left join MAIN_JGZDB jgzdb on sfx.fyzl=jgzdb.bh and sfx.JGID=jgzdb.JGID and jgzdb.JGZDLB_BH='Z00004' where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.pjzt=1 group by jgzdb.value4,a.jjks,a.jjys order by a.jjks,a.jjys,jgzdb.value4
select sum(d.SFXSJZFY) fy,a.jjks,a.jjys,jgzdb.value4 from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID left join HIS_SFZD_SFXMXB d on b.pkey=d.ZDZBPKEY and b.JGID=d.JGID left join HIS_YZ_MXB e on d.YZMX=e.pkey and d.JGID=e.JGID left join HIS_SFX sfx on d.sfx=sfx.bm and d.JGID=sfx.JGID left join MAIN_JGZDB jgzdb on sfx.fyzl=jgzdb.bh and sfx.JGID=jgzdb.JGID and jgzdb.JGZDLB_BH='Z00004' where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.CHPKEY is not null and c.SFZT != 0 group by jgzdb.value4,a.jjks,a.jjys order by a.jjks,a.jjys,jgzdb.value4
select count(*) num,jjks,jjys from (select distinct a.jjks,a.jjys,a.pkey from HIS_JZ_BASEINFO a left join HIS_SFZD_ZB b on a.pkey=b.jzpkey and a.JGID=b.JGID left join HIS_MZJS_MZFPZB c on b.pkey=c.GLZDBPKEY and b.JGID=c.JGID where a.JGID=? and (c.PJLX='MG' or c.PJLX='MS') and nvl(a.jjks,'%') like ? and c.SFRQ > ? and c.SFRQ <= ? and c.pjzt=1 ) group by jjks,jjys order by jjks,jjys