COUNTEQUAL
Function
Count the number of elements equal to a given target value within an array.
Syntax
COUNTEQUAL(arr, target)
Parameters
arr:ARRAY<T>, supported element types include numeric, boolean, string, datetime, and IP.target: same type as elements ofarr.
Return value
- Returns
BIGINT, representing the count of equal elements.
Usage notes
NULLequalsNULLfor this function and will be counted.
Examples
-
Basic
COUNTEQUAL([1,2,3,2], 2)->2COUNTEQUAL(['a','b','a'], 'a')->2COUNTEQUAL([true,false,false], false)->2
-
NULLis considered equal and will be countedCOUNTEQUAL([1,NULL,2,NULL], NULL)->2COUNTEQUAL([1,NULL,1], 1)->2COUNTEQUAL([1, 2], NULL)->0
-
If the array is
NULL, returnsNULLCOUNTEQUAL(NULL, 1)->NULL