GREATEST_FUNC

All functions > COMPARISON > GREATEST_FUNC

Returns the greatest (maximum) value from a list of arguments.

Syntax

GREATEST_FUNC(exprs)
sql

Arguments

ParameterTypeRequiredDescription
exprsARRAYBIGINTYesVariable 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

Examples

Numeric values

Other types

Last update at: 2025/10/13 10:23:46