select char(collid, 8) coll, char(progName, 8) pgm,
char(version, 12) vers,
bind_time,
count(*) cnt, min(timestamp) tst_min, max(timestamp) tst_max,
count(distinct timestamp) tsts,
count(distinct queryNo) ques,
COLLID, APPLNAME, PROGNAME, version
from cmnbatch.plan_table
where progName like 'YYWM0%'
group by COLLID, APPLNAME, PROGNAME, version, bind_time
order by progName, version, collid, bind_time
with ur