select A.BMBH00, A.BMMC00, A.CYRS00,--出院人数 A.ASWCS0,--按时完成数 decode(A.CYRS00,0,'0.00',decode(A.ASWCS0,0,'0.00',to_char(round(A.ASWCS0/A.CYRS00* 100 ,2),'fm9999990.9999')))||'%' ASWCL0--按时完成率 from(select A.BMBH00, A.BMMC00, (select count(distinct D.ZYID00) from ZS_BLXX01 D where A.BMBH00=D.DQKSBH and D.ZYID00=D.Zyid00 and D.CYRQ00>='20200401' and D.CYRQ00<='20200407') CYRS00,--出院人数 (select count(distinct C.LSH000) from BA_BRZYXX C,ZS_BLXX01 D where A.BMBH00=C.CYKB00 and c.LSH000=D.zyid00 and ( (to_date(C.SCTJRQ, 'yyyymmdd') - to_date(D.CYRQ00, 'yyyymmdd')) <= 3 or SCTJRQ<=nvl(gdtjrq,'00010101')) and D.CYRQ00>='20200401' and D.CYRQ00<='20200407') ASWCS0--按时完成数 from BM_BMBM00 A where A.FLAG00 = '1' and A.BMXZ00 in ('0', '9') and exists (select SSKSBH from ZS_YSZ000 where SSKSBH = A.BMBH00) order by BMBH00) A where A.BMBH00 in (select bmbh00 from bm_bmbm00 where yyid00='220006')