zOs/SQL/MVEXTGG

select count(*), rz, dbMbr
    from oa1p.tQZ050cmd
    group by rz, dbMbr
;
delete
    from oa1p.tQZ050cmd
    where rz = '?'
;
select count(*), rz, dbMbr
    from oa1p.tQZ050cmd
    group by rz, dbMbr
;
commit
;x;
select *
    from oa1p.tQZ050cmd
    where rz = '?'  and system like 'S2%'
    order by tst desc
; x;
delete from oa1p.tQZ050cmd c
    where rz = '?' and dbSys = '?' and verb = '?'
        and exists (select 1 from oa1p.tQZ050cmd o
           where o.rz = 'RZ2' and o.tst = c.tst and o.dbMbr = c.dbMbr
                and o.system = c.system and o.corr = c.corr
                and o.cmd = c.cmd)
;
commit
;
select count(*), rz
    from oa1p.tQZ050cmd
    group by rz