with e as
(
select count(*) c, progName pg, version vr, collid co, bind_time bt
from cmnBatch.plan_table
group by progName, version, collid, bind_time
)
select substr(e.pg, 1, 8) pg, p.pcTimeStamp, e.bt, c, vr,
e.*, p.*
from e
full outer join sysibm.sysPackage p
on e.co = p.collid and e.pg = p.name and e.vr = p.version
where e.pg = 'YYWM51E'
order by e.pg, p.pcTimeStamp desc, e.bt desc
with ur