ARRAY_MAX()

All functions > ARRAY > ARRAY_MAX()

Returns the largest value in an array using natural ordering.

Signatures

Returns: The largest value in the array, or NULL for empty arrays

ARRAY_MAX(array: ARRAY<T>) → T
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe array to find the maximum value from

Notes

  • Returns the maximum element using natural ordering
  • Ignores NULL values when determining the maximum
  • Returns NULL if array is empty or contains only NULL values
  • Works with numbers, strings, dates, or any comparable type
  • Uses lexicographic ordering for strings
  • Supports ARRAY<ROW> and ARRAY<ARRAY<T>>: ordering is lexicographic over field values / sub-array elements

See also

Examples

FeatureQL
SELECT
    -- Numeric maximum
    f1 := ARRAY_MAX(ARRAY(1, 5, 3)),
    -- Lexicographic maximum
    f2 := ARRAY_MAX(ARRAY('apple', 'zebra', 'banana')),
    -- Empty array
    f3 := ARRAY_MAX(ARRAY()::BIGINT[])
;
Result
f1 BIGINTf2 VARCHARf3 BIGINT
5zebranull

Last update at: 2026/06/20 10:08:10