zOs/SQL/CATCOMLT
with c as
(
select s.partitions parts, c.*
from sysibm.sysCopy c join sysibm.sysTablespace s
on c.dbName = s.dbName and c.tsName = s.name
where c.dbName like 'DB%'
and icType in ('F', 'I')
)
, d as
(
select icType
, case when parts > 0 then 'partd'
else strip(char(parts)) end prt
, case when dsNum = 0 and parts = 0 then 'p0dsNum0'
when dsNum > 0 and parts > 0 then 'p>dsNum>'
when dsNum = 0 and parts > 0 then 'p>dsNum0'
else 'p' || parts || 'dsNum' || dsNum
end partDsn
, case when lowDsNum = dsNum and highDsNum = dsnum then 'single'
when dsNum=0 and lowDsNum = 1 and highDsNum = parts then 'all'
else 'dsNum' || dsNum || 'low' || lowDsNum
|| 'high' || highDsNum
end dsNums
from c
)
, e as
(
select icType, copyPagesF
, case when parts = 0 then 'p0' else 'p>' end p
, case when dsNum = 0 then 'ds0' else 'ds>' end ds
from c
)
select count(*), sum(copyPagesF), icType, p, ds
from e
group by icType, p, ds