📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

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 │ └─────────┘

Was this page helpful?