create or replace view vw_bq_zgys_ydhl as
select b.zwxm00, b.xkh000, b.pysm00, b.wbsm00, b.ygbh00, a.bmbh00, a.xtdm00
  from xt_yhbmqx a, bm_ygbm00 b
 where a.ygbh00 = b.ygbh00 and b.ygxz00   in ('1','2')
   AND to_date(a.KSRQ00 || a.KSSJ00, 'yyyymmddhh24:mi:ss') <= sysdate
   and (a.jsrq00 is null or trim(a.jsrq00) is null or
       (to_date(a.JSRQ00 || a.JSSJ00, 'yyyymmddhh24:mi:ss') >= sysdate));
