MAX
The MAX scalar function returns the maximum value in a set of values.
The schema is SYSIBM.
The arguments must be compatible. For more information on compatibility, refer to the compatibility matrix in Table 1. All but the first argument can be parameter markers. There must be two or more arguments.
Each argument must be an expression that returns a value of any built-in data type other than a CLOB, DBCLOB, BLOB, ROWID, or XML.
Character string arguments and binary string arguments cannot have a length attribute greater than 32704, and graphic string arguments cannot have a length attribute greater than 16352.
The arguments are evaluated in the order in which they are specified. The result of the function is the maximum argument value.
The result can be null; if any argument is null, the result is the null value.
The selected argument is converted, if necessary, to the attributes of the result. The attributes of the result are determined using the Rules for result data types. If the MAX function has more than two arguments, the rules are applied to the first two arguments to determine a candidate result type. The rules are then applied to that candidate result type and the third argument to determine another candidate result type. This process continues until all arguments are analyzed and the final result type and CCSID is determined.
GREATEST can be specified as a synonym for MAX.
MAX(:M1,:M2,:M3)
MAX(:M1,:M2,:M3)