update mydt10, 
      (SELECT mydt10.nr01
       FROM eleo20_dels as eleo20
       LEFT JOIN mydt10 ON mydt10.tbl='eleo20'
                        && mydt10.tbl_nr01=eleo20.nr01
       WHERE eleo20.p031>=cast('{odbcdtos(nt_p01)}' as date)
          && eleo20.p031<=cast('{odbcdtos(nt_p02)}' as date)
/*          && eleo20.p0121>={nt_p03}
          && eleo20.p0121<={nt_p04}
*/          
          && eleo20.remddate>=cast('{odbcdtos(nt_p07d)}' as date)
          && eleo20.remddate<=cast('{odbcdtos(nt_p08d)}' as date)
          && concat(eleo20.remddate, eleo20.remdtime)>=concat(cast('{odbcdtos(nt_p07d)}' as date), '{nt_p07t}')
          && concat(eleo20.remddate, eleo20.remdtime)<=concat(cast('{odbcdtos(nt_p08d)}' as date), '{nt_p08t}')
          && {p_mydt10where} 
          && mydt10.nr01 is not null
       GROUP BY mydt10.nr01
      ) as tbl01 
SET mydt10.remguc='{p_mydt10mark}'
WHERE mydt10.nr01=tbl01.nr01
   && (    (mydt10.p01=1 && {nt_napost}=1)
        || (mydt10.p01=2 && {nt_nparal}=1)
      );
/*peg_end*/

update mydt10, eleo20
SET mydt10.remguc='{p_mydt10mark}'
WHERE mydt10.tbl='eleo20'
   && eleo20.p704>=cast('{odbcdtos(nt_p01)}' as date)
   && eleo20.p704<=cast('{odbcdtos(nt_p02)}' as date)
/*   && eleo20.p0121>={nt_p03}
   && eleo20.p0121<={nt_p04}
*/   && eleo20.remdate>=cast('{odbcdtos(nt_p07d)}' as date)
   && eleo20.remdate<=cast('{odbcdtos(nt_p08d)}' as date)
   && concat(eleo20.remdate, eleo20.remtime)>=concat(cast('{odbcdtos(nt_p07d)}' as date), '{nt_p07t}')
   && concat(eleo20.remdate, eleo20.remtime)<=concat(cast('{odbcdtos(nt_p08d)}' as date), '{nt_p08t}')
   && {p_mydt10where} 
   && eleo20.pakyro=1
   && (    (mydt10.p01=1 && {nt_napost}=1)
        || (mydt10.p01=2 && {nt_nparal}=1)
      );
/*peg_end*/
