MAX
Calculates the maximum value of a report parameter based on a condition.
Syntax
[GROUP] MAX(expression) [ WHERE condition]
- expression is the expression to be computed.
- condition is a boolean expression evaluated to compute the aggregate value.
Usage
For number, currency, and interval values, the
MAX(expression)
aggregate report instruction returns the maximum
value for expression among all records or among records qualified by the
WHERE
clause and any GROUP
specification.
For DATETIME
or DATE
data values,
greater than means later and less than means earlier in time.
Character strings are sorted depending on their first character.
If your program is executed in the default (U.S. English) locale,
for character data types, greater than means after in the ASCII
collating sequence, where a> A> 1, and less than means before
in the ASCII sequence, where 1< A< a.
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
.