GREATEST
functionsupportedCore SQL functionsReturns the largest value from a list of expressions. GREATEST supports all data types, including VARIANT.
Syntax
GREATEST( <expr1> [ , <expr2> ... ] )
Parameters
| Name | Required | Description |
|---|---|---|
<exprN> | required | The arguments must include at least one expression. All the expressions should be of the same type or compatible types. |
Returns
The first argument determines the return type: - If the first type is numeric, then the return type is ‘widened’ according to the numeric types in the list of all arguments. - If the first type is not numeric, then all other arguments must be convertible to the first type. If any argument is NULL, returns NULL.
Collation details
- The collation specifications of all input arguments must be compatible. - The comparisons follow the collation based on the input arguments’ collations and precedences. - The collation of the result of the function is the highest-precedence collation of the inputs.