zOs/SQL/EXDB2SEL

with f (fr, to) as
(  select min(timestamp), max(timestamp)
    from A540769.tadm60a1
)
, a as
(
select a.*, row_number() over(order by ssid, timestamp) ano
    from oa1a.tadm60a1 a join f
        on a.timestamp >= f.fr and a.timestamp <= f.to
    where ssid like 'DTB%'
)
, w as
(
select w.*, row_number() over(order by ssid, timestamp) wno
    from A540769.tadm60a1 w
)
select aNo, wNo,
       case when a.event_Type = w.event_type then 't' else '|' end
  ||   case when a.victim_plan = w.victim_plan then 'p' else '|' end
  ||   case when a.VICTIM_CORR_ID=w.VICTIM_CORR_ID then 'r' else '|' end
  ||   case when a.VICTIM_CONN_ID=w.VICTIM_CONN_ID then 'n' else '|' end
  ||   case when a.source_plan = w.source_plan then 'P' else '|' end
  ||   case when a.source_CORR_ID=w.source_CORR_ID then 'R' else '|' end
  ||   case when a.source_CONN_ID=w.source_CONN_ID then 'N' else '|' end
  ||   case when a.reason_COde = w.reason_code then 'e'
            when a.reason_COde = ''            then '+' else '|' end
  ||   case when a.type        = w.type        then 't'
            when a.type        = ''            then '+' else '|' end
  ||   case when a.name        = w.name        then 'n'
            when a.name = left(w.name, length(strip(a.name))) then '+'
                                             else '|' end
, a.*, w.*
    from w full outer join a
      on w.ssid = a.ssid and w.timestamp = a.timestamp
          and w.VICTIM_CORR_ID = a.VICTIM_CORR_ID
          and w.source_CORR_ID = a.source_CORR_ID
          and w.VICTIM_COnn_ID = a.VICTIM_COnn_ID
          and w.source_COnn_ID = a.source_COnn_ID
    order by value(w.ssid, a.ssid)
           , value(w.timestamp, a.timestamp)
           , value(w.VICTIM_CORR_ID, a.VICTIM_CORR_ID)
           , value(w.source_CORR_ID, a.source_CORR_ID)
           , value(w.VICTIM_COnn_ID, a.VICTIM_COnn_ID)
           , value(w.source_COnn_ID, a.source_COnn_ID)
 ;x;
select count(*)
    from A540769.tadm60a1;

select *
    from A540769.tadm60a1;

delete
    from A540769.tadm60a1;