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
└──────────────┘
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today