The GROUPING SETS Operator
The GROUP BY clause has been part of the SELECT statement syntax since the earliest dialects of T-SQL. You use GROUP BY to create queries that collapse multiple rows belonging to the same group into a single summary row and perform aggregate calculations (such as SUM and AVG) across the individual rows of each group. SQL Server 6.5 later extended the GROUP BY clause by adding the WITH CUBE and WITH ROLLUP operators. These operators perform additional grouping and aggregation of data in standard relational queries, similar to what is provided by online analytical processing (OLAP) queries that slice and dice your data into Analysis Services cubes, but without ever leaving the relational database world. SQL Server 2008 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access