zOs/SQL/PDBGENES

select id, rz, count(*), min(timeSTamp), max(timestamp)
    from A540769.tacct_general
    group by id, rz
;;;
set current schema = rz2DD;
-- insert into A540769.tacct_general
    with w  as
    (  select
           case
           when corrName like 'NIT16%'
                and log_recs_written > 30 then 'ni250Load'
           when plan_name = 'NI5310'      then 'ni250Update'
           when plan_name = 'NI5340'      then 'ni250Insert'
           when corrName like  'MFT15%'   then 'mfLoad'
           when corrName like  'MFT18%'   then 'mfPflege'
           when connect_id like 'MFT56%'  then 'mfTurnover'
           when corrName =     'MFT3100P' then 'mfAuswertung'
           else                                '' end id,
           left(current schema, 3) rz, g.*, current date insDate
         from tacct_general g
 -- ) , sel as
   )  select * from w where id <> ''  and timestamp >
                 current timestamp - 3 days
      order by timestamp desc
;
    ( select * from w where id <> ''
    )
      select * from sel
          where not exists (select 1
              from A540769.TACCT_GENERAL o
              where o.id = sel.id and o.rz = sel.rz
                  and o.timestamp = sel.timestamp
                  and o.subsystem_id = sel.subsystem_id
            )
;