O'Reilly logo
  • Dustin Waybright thinks this is interesting:

Here’s an example of a query using the ROLLUP clause based on the aforementioned hierarchy.

SELECT shipcountry, shipregion, shipcity, COUNT(*) AS numorders
FROM Sales.Orders
GROUP BY ROLLUP( shipcountry, shipregion, shipcity );


Cover of Training Kit (Exam 70-461): Querying Microsoft® SQL Server® 2012


In this case T-SQL rolls up the data, meaning shipcity doesn't have its own GROUP created.