Skip to main content

ARRAY_ANY

Returns the first non-NULL element from an array. Equivalent to ARRAY_AGGREGATE(<array>, 'ANY').

Syntax

ARRAY_ANY(<array>)

Return Type

Same as the array element type.

Examples

SELECT ARRAY_ANY(['a', 'b', 'c']) AS first_item;

┌────────────┐
│ first_item │
├────────────┤
│ a │
└────────────┘
SELECT ARRAY_ANY([NULL, 'x', 'y']) AS first_non_null;

┌────────────────┐
│ first_non_null │
├────────────────┤
│ x │
└────────────────┘
SELECT ARRAY_ANY([NULL, 10, 20]) AS first_number;

┌──────────────┐
│ first_number │
├──────────────┤
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