GREATEST_FUNC
All functions > COMPARISON > GREATEST_FUNC
Returns the greatest (maximum) value from a list of arguments.
Syntax
GREATEST_FUNC(exprs)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
exprs | ARRAYBIGINT | Yes | Variable number of expressions to compare (minimum 1) |
Returns
Same type as the input arguments - the maximum value
Notes
- All arguments must be of the same or compatible types
- If any argument is NULL, the result is NULL
- For strings, uses lexicographic (dictionary) ordering
- For dates/timestamps, returns the latest date/time
- Can accept any number of arguments (not just two)
- Equivalent to finding the maximum value across multiple columns