Cube Abril 7, 2008
Posted by heliodias in Uncategorized.add a comment
GROUP BY CUBE( a, b, c) is equivalent to
GROUP BY GROUPING SETS ( (a, b, c), (a, b), (b, c), (a, c), (a), (b), (c), ( )).
Grouping sets Abril 7, 2008
Posted by heliodias in Uncategorized.add a comment
SELECT a, b, SUM( c ) FROM tab1 GROUP BY GROUPING SETS ( (a,b), a)
SELECT a, b, SUM( c ) FROM tab1 GROUP BY a, b UNION
SELECT a, null, SUM( c ) FROM tab1 GROUP BY a