Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The GROUPING SETS clause in GROUP BY allows us to specify more than one GROUP BY options in the same record set. All GROUPING clause query can be logically expressed in terms of several GROUP BY queries connected by UNION. Table-1 shows several such equivalent statements. This is helpful in forming the idea of the GROUPING SETS clause. A blank set ( ) in the GROUPING SETS clause calculates the overall aggregate.

*bold*Table 1 - GROUPING SET queries and the equivalent GROUP BY queries
Set A - Aggregate Query with GROUPING SETS
Set B - Equivalent Aggregate Query with GROUP BY

...