GROUP BY
This statement is equivalent to:
SELECT a, b, SUM( c ) FROM tab1 GROUP BY a, b
UNION
UNION
SELECT null, b, SUM( c ) FROM tab1 GROUP BY b
UNION
SELECT null, null, SUM( c ) FROM tab1
indicates whether a specified column expression in a GROUP BY list is aggregated or not. GROUPING returns 1 for aggregated or 0 for not aggregated in the result set.
groupSet
is a set of expression or column or it’s alias appearing in the query block’s SELECT list. groupSet ::= { ( expr [ , expr [ , ... ] ] )}
expr
is expression or column or it’s alias appearing in the query block’s SELECT list.
SELECT a, b, SUM( c ) FROM tab1 GROUP BY GROUPING SETS ( (a, b), (a), (b), ( ) );
SELECT a, b,c, SUM( d ) FROM tab1 GROUP BY ROLLUP(a,b,c)
SELECT a, b,c, SUM( d ) FROM tab1 GROUP BY CUBE(a,b,c)
ROLLUP(a,b,c)
is equivalent to GROUPING SETS
as follows:
is equivalent to GROUPING SETS
as follows:
GROUPING SETS (
( a, b ),
( a, c ),
( a ),
( b, c ),
( b ),
( c ),
)
GROUP, GROUPING, GROUPING_ID, GROUPING_SETS, GROUPING SETS, CUBE, ROLLUP