
-- gb_12a.sql
-- original

set autotrace off echo off

col c1 format a10
col c2 format a10
col bit_1 format a10
col bit_0 format a10

with rowgen as (
   select 'ROW# ' || rownum c1, null c2
   from dual
   connect by level <= 2
)
select
   c1,c2
   , decode(grouping(c1),1,'SA NULL',nvl(c1,'DATA NULL')) bit_1
   , decode(grouping(c2),1,'SA NULL',nvl(c2,'DATA NULL')) bit_0
   , grouping_id(c1,c2) gid
from rowgen
group by cube(c1,c2)  -- c1,c2 correspond to bit 1 and bit 0 in a bit vector
order by 5

l

/


