Micah
4Penny.net
Points: 7559

11/3/2011 1:44:01 PM

SQL - Group by Grouping Sets examples

* This article, and all our great SQL (General) documentation, Is available on the SQL (General) menu

I’m trying to get the hang of the ‘Group By Grouping Sets’ syntax, and I’m always having to look it up. Here is a quick little bit of example code that will get you started

GROUPING SETS ( )

Specifies multiple groupings of data in one query. Only the specified groups are aggregated instead of the full set of aggregations that are generated by CUBE or ROLLUP. The results are the equivalent of UNION ALL of the specified groups. GROUPING SETS can contain a single element or a list of elements. GROUPING SETS can specify groupings equivalent to those returned by ROLLUP or CUBE. The <grouping set item list> can contain ROLLUP or CUBE.

( )

The empty group generates a total

4Penny.net
Version: Unknown or N/A
Section: SQL Scripts
Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
3