CUBE

The ROLLUPs that we have seen are a small percentage of the numerous possible combinations. For example, the ROLLUP option in Listing 9.1 computed subtotals for gender. Suppose the business analyst wanted to get subtotals for Department while still rolling up the costs of gender per department. This would require the GROUP BY clause to change to the following:

				Group by rollup (department, gender)
			

Suppose the business analyst also wanted to subtotal costs for gender and department. This cannot be done with the ROLLUP option because the SELECT clause can contain only one GROUP BY clause (and only one ROLLUP option). The CUBE option must be used instead.

The CUBE option will compute subtotals for all expressions placed within the parameter ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.