Press "Enter" to skip to content

ROLLUP, CUBE, and GROUPING SETS in T-SQL

Louis Davidson works with three amigos:

To get the total, there are a few ways, which I will demonstrate in the next sections on the aggregation functions, ROLLUP, CUBE, and then GROUPING SETS. Grouping sets are the most flexible, in that they let you do what the other two can do, but with more control. But knowing the others is important because it is how most ad hoc queries will be written.

It’s uncommon that I use GROUPING SETS() in my code, but every time I do, I’m thankful that it exists.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.