zOs/SQL/PDBGENEY

set current schema A540769;
select id, rz,  count(*), min(insDate), max(insDate)
    from tacct_general
    group by id, rz
    order by 1 desc, 2 asc
;
commit
;;;
select insDate, rz,  count(*)
    from tacct_general
    group by insDate, rz
    order by 1 desc, 2 asc
;
set current schema rr2xx;
-- insert into A540769.tacct_general
    with w  as
    (  select
           case
           when corrName like 'NIT15%'        then 'ni150load'
           when corrName like 'NIT16%' and log_recs_written > 30
                                              then 'ni250Load'
           when CONNECT_ID like 'NIT17%'      then 'ni150InsEmptyClu'
           when CONNECT_ID like 'NIT18%' or plan_name = 'NI5392'
                                              then 'ni250InsNoPos'
           when plan_name = 'NI5310'          then 'ni250Update'
           when plan_name = 'NI5340'          then 'ni250Insert'
           else                                '' end id,
           left(current schema, 3) rz, g.*, current date insDate
         from tacct_general g
         where timestamp > '2011-04-14-00.00.00'
    ) , sel as
    ( select * from w where id <> ''
    )
 select * from sel
     order by date(timestamp) desc, id, timestamp
     with ur
 ;;;
      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
            )
;
set current schema = 'A540769';
select insDate, rz, count(*)
    from tacct_general
    group by insDate, rz
    order by 1 desc, 2 asc
;
select date(timestamp), rz, count(*)
    from tacct_general
    group by date(timestamp), rz
    order by 1 desc, 2 asc
;
select *
    from tacct_general
update tacct_general set id = 'ni150InsEmpClu'
               where    id = 'ni150InsEmptyCl'
;