ROLLUP

ROLLUP is an extension or option available for the GROUP BY clause. It allows the user to compute subtotals and totals for groups of data. It is highly efficient and adds little overhead to the SELECT statement. A syntax template of the option is as follows:

				Group By rollup
				(expression1, expression2)
			

The ROLLUP keyword will cause a cumulative subtotal row to be created for each of the expressions. When multiple expressions are placed in the parameter list, Oracle will create a grand total for the right-most expression and a subtotal for each of the left-most expressions.

The ROLLUP rows can be identified by null values. The grand-total row will have only the grand-total values. All other row values will be null. If a subtotal is computed, ...

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.