ARRAY_MIN()

All functions > ARRAY > ARRAY_MIN()

Returns the smallest value in an array using natural ordering.

Signatures

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

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

Notes

  • Returns the minimum element using natural ordering
  • Ignores NULL values when determining the minimum
  • 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
    f1 := ARRAY_MIN(ARRAY[1, 5, 3]), -- Numeric minimum
    f2 := ARRAY_MIN(ARRAY['apple', 'zebra', 'banana']), -- Lexicographic minimum
    f3 := ARRAY_MIN(ARRAY[]::BIGINT[]) -- Empty array
;
Result
f1 BIGINTf2 VARCHARf3 BIGINT
1applenull

Last update at: 2026/05/26 17:22:09