zOs/SQL/GBGRSPHX
-- table Space und Details History / Zeitreihe
set current path oa1p;
with d (d,l) as
(
select current date, 0
from sysibm.sysDummy1
union all select d - 3 days, l+1
from d
where l < 999999 and d >= current date - 1 months
)
, t1 as
(
select rz, dbSys, dbName, name, instance, partition
from oa1p.tqz006GbGrTsSTats
where rz = 'RZ2' and dbSys = 'DBOF'
and dbName like 'XC%'
and name like 'A102A%'
group by rz, dbSys, dbName, name, instance, partition
)
, t2 as
(
select d.d, t1.*, (select max(loadTs) from oa1p.tqz006GbGrTsSTats r
where t1.rz = r.rz and t1.dbSys = r.dbSys
and t1.dbName = r.dbName
and t1.name = r.name
and t1.instance = r.instance
and t1.partition = r.partition
and loadTs < timestamp(d.d + 1 day)
) loadTs
from t1, d
)
, t as
(
select d, r.*
from t2
join oa1p.tqz006GbGrTsSTats r
on t2.loadTS is not null and r.state <> 'd'
and t2.rz = r.rz
and t2.dbSys = r.dbSys
and t2.dbName = r.dbName
and t2.name = r.name
and t2.instance = r.instance
and t2.partition = r.partition
and t2.loadTs = r.loadTS
)
select rz, dbSys, dbName, name
-- , smallInt(partition) part
, d
, substr(fosFmte7(sum(real(nActive) * pgSize * 1024)), 1, 7) used
, substr(fosFmte7(sum(totalRows)), 1, 7) rows
from t
group by rz, dbSys, dbName, name, d
order by rz, dbSys, dbName, name
, d desc
;