The MAX aggregate function returns the maximum value in a set of values in a group.
The data type and length attribute of the result are the same as the data type and length attribute of the argument values. When the argument is a string, the result has the same CCSID as the argument.
If a sort sequence other than *HEX is in effect when the statement that contains the MAX function is executed and the arguments are SBCS data, mixed data, or Unicode data, then the result is obtained by comparing weighted values for each value in the set. The weighted values are based on the sort sequence.
The function is applied to the set of values derived from the argument values by the elimination of null values.
The result can be null. If the function is applied to the empty set, the result is a null value. Otherwise, the result is the maximum value in the set.
The specification of DISTINCT has no effect on the result and is not advised.
SELECT MAX(SALARY) /12 INTO :MAX_SALARY FROM EMPLOYEEResults in MAX_SALARY being set to 4395.83.
SELECT MAX(PROJNAME) INTO :LAST_PROJ FROM PROJECTResults in LAST_PROJ being set to 'WELD LINE PLANNING '.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.