COUNT_ITEM

Syntax

COUNT_ITEM( array, value )

Description

Returns the number of elements in the array array equal to value. The type of value must match the type of the array elements.

Argument types:

  • arrayArray of fractional numbers | Array of integers | Array of strings
  • valueFractional number | Integer | String

Return type: Integer

Examples

COUNT_ITEM(ARRAY(1, 2, 2, 3), 2) = 2
COUNT_ITEM(ARRAY(1, 2, 2, 3), 4) = 0
COUNT_ITEM(ARRAY(1, NULL, 2, NULL), NULL) = 2

Data source support

ClickHouse 21.8, PostgreSQL 9.3.