CUBE and ROLLUP
CUBE and ROLLUP are options available to queries that contain a GROUP BY clause. They are useful for applications that need to provide a changing variety of data aggregations based on varying sets of attributes or dimensions. (In the context of cubes, the word dimension is often used, either as a synonym for attribute or to describe a domain of values for an attribute.) I’ll first describe the CUBE option, and then follow with a description of the ROLLUP option, which is a special case of CUBE.
Imagine that your application needs to provide the users with the ability to request custom aggregates based on various sets of dimensions. Say, for example, that your base data is the Orders table that I used earlier in the chapter, ...