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