Skip to main content

ARRAY_MAX

Returns the largest numeric value in an array. NULL elements are skipped; non-numeric values cause an error.

Syntax

ARRAY_MAX(<array>)

Return Type

Same numeric type as the array elements.

Examples

SELECT ARRAY_MAX([5, 2, 9, -1]) AS max_int;

┌─────────┐
│ max_int │
├─────────┤
9
└─────────┘
SELECT ARRAY_MAX([1.5, -2.25, 3.0]) AS max_decimal;

┌─────────────┐
│ max_decimal │
├─────────────┤
3.00
└─────────────┘
SELECT ARRAY_MAX([NULL, 10, 4]) AS max_with_null;

┌───────────────┐
│ max_with_null │
├───────────────┤
10
└───────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today