Skip to content

COUNT_IF

COUNT_IF

Compute the total number of occurrences of true in a column/group/window of booleans. For example:

SELECT COUNT_IF(A) FROM table1

Is equivalent to

SELECT SUM(CASE WHEN A THEN 1 ELSE 0 END) FROM table1