nmax, nmin - Numeric Extremum Functions
... nmax|nmin( val1 = arg1 val2 = arg2 [val3 = arg3] ... [val9 = arg9] ) ...
These functions return the value of the greatest or the least of the arguments passed. A minimum of
arg2, and a maximum of
nine arguments must be passed. Here, the optional input parameters
val9 must be filled in ascending order without gaps. The arguments
numeric expression positions.
The following applies to the data type of the return value:
- Outside of an arithmetic expression, a calculation type is determined from all the arguments, and it is used to perform the comparison. The calculation type is determined just like an arithmetic expression and also determines the data type of the return value.
- In an arithmetic expression, the arguments of the function contribute to the calculation type of the entire expression and the function is calculated using the calculation type. If an argument itself is an arithmetic expression, its operands contribute to the entire calculation type and the argument is also calculated using this type.
The extremum functions
cmincan be used to determine character-like extreme values.
When using two input parameters:
result = nmax|nmin( val1 = arg1 val2 = arg2 )
the evaluation of the functions is equivalent to:
IF num1 >= num2 | num1 <= num2.
result = num1.
result = num2.
Determines the lesser of two time stamps in packed numbers. Here, the initial value of the conditional
COND is not regarded as the least value.
CONSTANTS max_ts TYPE timestamp VALUE 999999999999999. DATA: ts1 TYPE timestamp, ts2 TYPE timestamp. GET TIME STAMP FIELD ts1. DATA(min_ts) = nmin( val1 = COND timestamp( WHEN ts1 IS INITIAL THEN max_ts ELSE ts1 ) val2 = COND timestamp( WHEN ts2 IS INITIAL THEN max_ts ELSE ts2 ) ).