SUM

Calculates the total of a report parameter based on a condition.

Syntax

[GROUP] SUM(expression) [ WHERE condition]
  1. expression is the expression to be computed.
  2. condition is a boolean expression evaluated to compute the aggregate value.

Usage

This aggregate report instruction evaluates as the total of expression among all records or among records qualified by the optional WHERE clause and any GROUP specification.

Using the GROUP keyword causes the aggregate instructions to include only data of the current group of records that have the same value for the variable that you specify in the AFTER GROUP OF control block.

Input records for which the expression evaluates to NULL values are ignored.

By default, if all input record values are NULL , the result of the aggregate is NULL. However, you can control this behavior and force the runtime system to return zero instead of NULL with the report.aggregateZero FGLPROFILE parameter.

This aggregate instruction makes a two-pass report when not using the GROUP keyword and is used in any control block other than ON LAST ROW.