select count(*), relBound, min(bindTime), max(bindTime)
from sysibm.sysPackage p
group by relBound
;
with o as
(
select case when lastUsed > current date - 1 month
then 'used' else 'old ' end
|| case when timestamp > '2015-04-09-23.59.59'
then ' pkgV11' else ' pkgOld' end no
, p.*
from sysibm.sysPackage p
)
select count(*), no, relBound
from o
group by no, relBound