zOs/SQL/GUIDO

set current query acceleration all;
set current application compatibility 'V11R1';
with u as
(  -- cpu pro occurrence
 SELECT occurrences occ
     , EDB2TCB / occurrences c2c
   FROM Pbdd.TACCT_GENERAL
   where date(DATETIME) = '2016-08-29'
   and occurrences > 0
)
,  v as
(  -- gruppiere by cpu
 SELECT count(*) cnt
     , sum(occ) occ
     , c2c
   FROM u
   GROUP BY c2c
)
, w as
( -- gruppiere by cpu range: 3 range pro 10er Potenz
  select
      sum(occ) occ
    , sum(c2c*occ) / sum(occ) c2c
    , min(c2c) c2cMin
    , max(c2c) c2cMax
    from v
    group by        floor(log10(max(c2c, 1e-9)) * 3)
)
, x as
( -- füge die laufenden Totale dazu
 select occ occ1
    , sum(occ) over( order by c2cMin
                    range between unbounded preceding and current row
                   )  occCum
    , c2c c2c1
    , sum(c2c) over( order by c2cMin
                    range between unbounded preceding and current row
                   )  c2cCum
     , w.*
   from w
)
select *
    from x
    order by c2cMin