zOs/SQL/GBGRMID3
select current date - 2 years
, date(trunc_timestamp(timestamp(current date - 2 years + 3 days)
, 'iw') - 3 days)
, date(trunc_timestamp(
trunc_timestamp(timestamp(current date - 5 years + 3 days)
, 'iw') - 3 days, 'mon'))
from sysibm.sysdummy1;x;
select *
from oa1p.tqz006gbgrtsstats where state = 'D' ;d;
where dssize < 0
order by d.db, d.ts, d.partition, d.datum desc
;x;
select d.db, d.ts, d.partition, d.datum, w.datum
from oa1p.tqz006tmp d
left join oa1p.tqz006tmp w
on w.p = 3 and w.db = d.db and w.ts = d.ts
and w.partition = d.partition and w.datum = d.datum
where d.p = 2 and d.db = 'QZ01A1P'