CREATE OR REPLACE VIEW SD_HOSPITAL.VW_YK_YPSYQKTJ
 (
 MZZYBZ, ZYID00, YPNM00, YPMC00, YPGG00, DDD000, YPZSL0, LSDJ00, FYRQ00, 
ZHL000, KSSJB0, YSGZH0, KCDWSL, KCDW00, DQBQ00, YPBM00

 )
 AS 
select 2 MZZYBZ,b.ZYID00,b.YPNM00,b.YPMC00,b.YPGG00,c.DDD000,b.YPZSL0,b.LSDJ00,b.FYRQ00,b.ZHL000,
c.KSSJB0,b.YSGZH0,round(b.YPZSL0*b.ZHL000/c.K2J000,2) KCDWSL,c.KCDW00,b.bqbmbh,c.YPBM00
  from YF_YZYPSQ b,BM_YD0000 c where b.YPNM00=c.YPNM00 and b.zyid00 in (select zyid00 from zy_brxxb0 where ybzxlb in ('@','#'))
union all
select 2 MZZYBZ,b.ZYID00,d.YPNM00,d.YPMC00,d.YPGG00,c.DDD000,d.YPZSL0,d.LSDJ00,b.FYRQ00,d.ZHL000,
c.KSSJB0,b.YSGZH0,round(d.YPZSL0*d.ZHL000/c.K2J000,2) KCDWSL,c.KCDW00,b.dqbq00,c.YPBM00
  from YF_ZYCF00 b,YF_ZYCFMX d,BM_YD0000 c where b.CFLSH0=d.CFLSH0 and d.YPNM00=c.YPNM00 and b.zyid00 in (select zyid00 from zy_brxxb0 where ybzxlb in ('@','#'))
union all
select 1 MZZYBZ,b.GHID00,d.YPNM00,d.YPMC00,d.YPGG00,c.DDD000,d.YPZSL0,d.LSDJ00,b.FYRQ00,d.ZHL000,
c.KSSJB0,b.YSGZH0,round(d.YPZSL0*d.ZHL000/c.K2J000,2) KCDWSL,c.KCDW00,b.ghks00,c.YPBM00
  from YF_MZCF00 b,YF_MZCFMX d,BM_YD0000 c where b.CFLSH0=d.CFLSH0 and d.YPNM00=c.YPNM00
/
