
-- gb_14a.sql
-- original
-- show that for 1 argument rollup() and cube() produce the same results

set autotrace off echo off

with rowgen as (
   select
      'GROUP# ' || to_char(mod(rownum,9)+1,'99') grpid
      , rownum value
   from dual
   connect by level <= 100
)
select grpid, sum(value) value
from rowgen
group by cube(grpid)
order by grouping(grpid), grpid

l

/

with rowgen as (
   select
      'GROUP# ' || to_char(mod(rownum,9)+1,'99') grpid
      , rownum value
   from dual
   connect by level <= 100
)
select grpid, sum(value) value
from rowgen
group by rollup(grpid)
order by grouping(grpid), grpid

l

/

