zOs/SQL/BIPA9LT7

with a as
(
select appl a, pgm p , collid c,
     strip(ssid) || '>' || strip(location) || '-' || strip(qualifier) t
    from oa1p.bind_exceptions
    where ssid <> 'DAEG'
)
, b as
(    select a, p, c,
         row_number() over(partition by a, p, c
                       order by t) l,
         t
     from a
)
, c (a, p, c, l, t, u) as
(    select a, p, c, 1, t, varchar(t, 2000) from b where l = 1
     union all select c.a, c.p, c.c, c.l+1, b.t, c.u || ' ' || b.t
          from b, c
          where b.a = c.a and b.p = c.p and b.c = c.c and b.l = c.l+1
                and c.l < 100
)
, d as
(
    select a, p, c, max(l) l, min(t) tFr, max(t) tTo, max(u) t
      from c
      group by a, p, c
)
, e as
( select
   case when a in ('A18Q', 'DBTST', 'DB2J')  then '-'
        when p = 'AU5070' or p like 'YAU03%' then 'DBOF>DVBP'
        when p = 'YCDPUT2' then '-'
        when l = 12 and tFr = 'DBBA>-OA1A'
             and left(tTo, 17) = 'DVTB>CHSKA000DBTF' then 'DVBP>DBOF'
        when l > 4  and tFr = 'DBAF>-OA1A'
             and tTo = 'DBTF>CHSKA000DVTB-OA1T' then 'DBOF>DVBP'
        when t = 'DBOF>-OA1P DBOF>CHSKA000DBOL-OA1P' then 'DBOF>DBOL'
        else '???'
   end n,
   d.* from d
)
select * from e ;x;
select min(n), max(n), count(*), l, tFr, tTo, t
    from e
    group by l, tFr, tTo, t
    order by tFr, tTo, l
;x;