Skip to main content

ARRAY_COUNT

Counts the non-NULL elements in an array.

Syntax

ARRAY_COUNT(<array>)

Return Type

BIGINT

Examples

SELECT ARRAY_COUNT([1, 2, 3]) AS cnt;

┌─────┐
│ cnt │
├─────┤
3
└─────┘
SELECT ARRAY_COUNT([1, NULL, 3]) AS cnt_with_null;

┌──────────────┐
│ cnt_with_null│
├──────────────┤
2
└──────────────┘
SELECT ARRAY_COUNT(['a', 'b', NULL]) AS cnt_text;

┌─────────┐
│ cnt_text│
├─────────┤
2
└─────────┘
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