Sign Up Now! Log In
Micah 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


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

Version: Unknown or N/A
Section: SQL Scripts