GREATEST scalar function
The GREATEST function returns the maximum value in a set of values.
The schema is SYSIBM.
-
expression
-
An expression that returns a value of any built-in data type or user-defined data type that is comparable with the data type of the other argument. The data type cannot be a LOB, distinct type based on a LOB, XML, array, cursor, row, or structured type.
Result
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 any argument is null.
The selected argument is converted, if necessary, to the attributes of the
result. The attributes of the result are determined by the data types of all the arguments as
explained in Rules for result data types
.
Notes
- The GREATEST scalar function is a synonym for the MAX scalar function.
- The GREATEST function cannot be used as a source function when creating a user-defined function. Because this function accepts any comparable data types as arguments, it is not necessary to create additional signatures to support user-defined data types.
Example
SELECT GREATEST (C1, C2, C3) FROM T1
returns
7.If column C3 has a value of null instead of 4, the same query returns the null value.