MAX

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram                       .---------------.
                       V               |
>>-MAX--(--expression----,--expression-+--)--------------------><
 

The MAX scalar function returns the maximum value in a set of values.

The arguments must be compatible. Character-string arguments are compatible with datetime values. The arguments cannot be DataLink values.

expression
The arguments must be any built-in numeric or string data types. If one of the arguments is numeric, then character and graphic string arguments are cast to numeric before evaluating the function.

The result of the function is the largest argument value. The result can be null if at least one argument can be null; the result is the null value if one of the arguments is null.

The selected argument is converted, if necessary, to the attributes of the result. The attributes of the result are determined by all the operands as explained in Rules for result data types.

If a sort sequence other than *HEX is in effect when the statement is executed and the arguments are SBCS data, mixed data, or Unicode data, the weighted values of the strings are compared instead of the actual values. The weighted values are based on the sort sequence.

Examples