ARRAY_COUNT

Returns the total number of non-null elements in an array.  To count all elements including nulls, use ARRAY_LENGTH

Behavior Type

Immutable

Syntax

ARRAY_COUNT(array)

Supported Data Types

1D arrays of:

  • BOOLEAN
  • INTEGER
  • FLOAT
  • NUMERIC
  • STRING/VARCHAR
  • TIMESTAMP
  • TIMESTAMPTZ
  • UUID
  • INTERVAL

Null-Handling

Null values are not included in the count.

Example

=> SELECT array_count(ARRAY[1.2,NULL,3,7.6,8,5]);
array_count
-------------
5
(1 row)