zOs/SQL/PRPGKACC

set current path = oa1p;
with x as
( select smallint(floor(log10(max(1e-30,
                  real(BPGETPAGE)/sqlCount)) * 3)) g, p.*
      from pbxx.TACCT_PROGRAM_20131015 p
      where sqlCount > 0
      fetch first 1000000 rows only
)
select count(*), g
    , substr(fosFmte7(min(real(BPGETPAGE)/sqlCount)), 1, 7) bpGetMi
    , substr(fosFmte7(max(real(BPGETPAGE)/sqlCount)), 1, 7) bpGetMa
    , substr(fosFmte7(avg(real(BPGETPAGE)/sqlCount)), 1, 7) bpGet
    , min(dateTime)
    , max(dateTime)
    , min(subsystem), max(subsystem)
    , min(planName), max(planName)
    , min(programName), max(programName)
    from x
    group by g
    order by g desc