zOs/SQL/GBGRMID2
select p, dsSize, count(*)
from oa1p.tqz006tmp
where p=2
group by p, dsSize
;c;
with u as
(
select *
from oa1p.tqz006tmp2 s
where db like 'DB2PDB%'
and hiUse <> (select hiUse
from oa1p.tqz006tmp2 a
where s.db = a.db and s.ts = a.ts
and s.partition = a.partition and s.datum > a.datum
order by a.datum desc
fetch first 1 rows only
)
)
, d as
(
select * from u d
where not exists (select 1 from oa1p.tqz006GbGrTsStats s
where s.rz = 'RZ4' and s.dbSys = 'DP4G'
and s.dbName = d.db and s.name = d.ts
and s.partition = d.partition
)
and not exists (select 1 from oa1p.tqz006tmp2 o
where d.db = o.db and d.ts = o.ts
and d.partition = o.partition and d.datum < o.datum
)
)
, w as
(
select * from u w
where not exists (select 1 from u n
where w.db = n.db and w.ts = n.ts
and w.partition = n.partition
and w.datum < n.datum
and n.datum <= date(trunc_timestamp(
timestamp(w.datum)+9 days, 'iw')-3 days) -- next friday
)
)
select * from w
order by db, ts, partition, datum desc
;x;
order by db, ts, partition, datum desc
select count(*)
from oa1p.tqz006tmp2 s
where db = 'DB2ADMIN'
;
with s (d, l) as
( select current date, 0 from sysibm.sysDummy1
union all select d - 1 day, l+1 from s where l < 20
)
select d
, date(trunc_timestamp(timestamp(d), 'iw')) "iw"
, date(trunc_timestamp(timestamp(d)+6 days, 'iw')) "nxMon"
, date(trunc_timestamp(timestamp(d)+9 days, 'iw')-3 days) "nxFri"
from s
;x;