Subtotals

The COMPUTE command is often used with the BREAK command and is used to calculate subtotals at breakpoints because summary totals are a very desirable report feature. The COMPUTE command, however, cannot be used without a complimentary BREAK command and is often confused with the group functions. In essence, they compute the same value. The difference is that the COMPUTE command allows the display of the detail (or grouped) records, while the GROUP BY clause used with the function compresses them into a single row.

The COMPUTE command is a format command, and it will reside in memory until cleared with the CLEAR COMPUTES command or until over-written with a new command. The structure of the command is as follows:

				Compute
				value(s) ...

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.