update heru01
set remguc=''
where remguc='@2del-mass@';
/*peg_end*/

update heru01, 
         (SELECT heru01.p00 as p00, 
                 max(concat(heru01.remdate, heru01.remtime)) as maxd, 
                 sum(1) as plit
          FROM heru01
          GROUP BY heru01.p00
          HAVING plit>1
         ) as heru01_1
SET heru01.remguc='@2del-mass@'
WHERE heru01.p00=heru01_1.p00
   && concat(heru01.remdate, heru01.remtime)<>heru01_1.maxd;
/*peg_end*/ 

update z29
set remguc=''
where remguc='@2del-mass@';
/*peg_end*/

update z29, 
         (SELECT z29.z28 as z28, 
                 z29.z30 as z30,
                 max(concat(z29.remdate, z29.remtime)) as maxd, 
                 sum(1) as plit
          FROM z29
          GROUP BY z29.z28, z29.z30
          HAVING plit>1
         ) as z29_1
SET z29.remguc='@2del-mass@'
WHERE z29.z28=z29_1.z28
   && z29.z30=z29_1.z30
   && concat(z29.remdate, z29.remtime)<>z29_1.maxd;
/*peg_end*/ 
