DB2 Version 10.1 for Linux, UNIX, and Windows

MAX aggregate function

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

Read syntax diagramSkip visual syntax diagram
           .-ALL------.                  
>>-MAX--(--+----------+--expression--)-------------------------><
           '-DISTINCT-'                  

The schema is SYSIBM.

expression
An expression that returns a value of any built-in data type other than a BLOB, CLOB, DBCLOB, or XML.

The data type, length and code page of the result are the same as the data type, length and code page of the argument values. The result is considered to be a derived value and can be null.

The function is applied to the set of values derived from the argument values by the elimination of null values.

If the function is applied to an 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 therefore is not recommended. It is included for compatibility with other relational systems.

Notes

Examples