O'Reilly logo

Microsoft® SQL Server 2008 R2 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

GROUPING SETS

The CUBE and ROLLUP operators allow you to run a single query and generate multiple sets of groupings. However, the sets of groupings are fixed. For example, if you use GROUP BY ROLLUP (A, B, C), you get aggregates generated for the following groupings of nonaggregate columns:

GROUP BY A, B, C

GROUP BY A, B

GROUP BY A

• A super-aggregate for all rows

If you use GROUP BY CUBE (A, B, C), you get aggregates generated for the following groupings of nonaggregate columns:

GROUP BY A, B, C

GROUP BY A, B

GROUP BY A, C

GROUP BY B, C

GROUP BY A

GROUP BY B

GROUP BY C

• A super-aggregate for all rows

SQL Server 2008 introduces the GROUPING SETS operator in addition to the CUBE and ROLLUP operators for performing several ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required