with cb as (
	select 1 c1, 2 c2, 1 val
	from dual
	union all
	select 1 c1, 2 c2, 1 val
	from dual
)
select c1,c2, sum(val) val
from cb
group by cube(c1,c2)
order by c1,c2
/
