update mydt10, 
      (SELECT mydt10.nr01
       FROM tran01_dels as tran01
       LEFT JOIN mydt10 ON mydt10.tbl='tran01'
                        && mydt10.tbl_nr01=tran01.nr01
       WHERE tran01.p014>=cast('{odbcdtos(nt_p01)}' as date)
          && tran01.p014<=cast('{odbcdtos(nt_p02)}' as date)
          && tran01.p704>={nt_p03}
          && tran01.p704<={nt_p04}
          && tran01.remddate>=cast('{odbcdtos(nt_p07d)}' as date)
          && tran01.remddate<=cast('{odbcdtos(nt_p08d)}' as date)
          && concat(tran01.remddate, tran01.remdtime)>=concat(cast('{odbcdtos(nt_p07d)}' as date), '{nt_p07t}')
          && concat(tran01.remddate, tran01.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, tran01, tran01 as tran01_1
SET mydt10.remguc='{p_mydt10mark}'
WHERE mydt10.tbl='tran01'
   && tran01.p014>=cast('{odbcdtos(nt_p01)}' as date)
   && tran01.p014<=cast('{odbcdtos(nt_p02)}' as date)
   && tran01.p704>={nt_p03}
   && tran01.p704<={nt_p04}
   && tran01.remdate>=cast('{odbcdtos(nt_p07d)}' as date)
   && tran01.remdate<=cast('{odbcdtos(nt_p08d)}' as date)
   && concat(tran01.remdate, tran01.remtime)>=concat(cast('{odbcdtos(nt_p07d)}' as date), '{nt_p07t}')
   && concat(tran01.remdate, tran01.remtime)<=concat(cast('{odbcdtos(nt_p08d)}' as date), '{nt_p08t}')
   && {p_mydt10where} 
   && tran01_1.nr01=mydt10.tbl_nr01
   && tran01_1.pa00=tran01.nr01
   && (    (mydt10.p01=1 && {nt_napost}=1)
        || (mydt10.p01=2 && {nt_nparal}=1)
      );
/*peg_end*/
