COUNT_IF
All functions > AGGREGATE > COUNT_IF
Returns the number of values in the group that are true.
Syntax
COUNT_IF(expr, group_by, where)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
expr | BOOLEAN | Yes | The boolean condition to evaluate |
Returns
The number of TRUE values in the group
Notes
- Counts how many values evaluate to TRUE
- Equivalent to COUNT(CASE WHEN expr THEN 1 END)
- NULL and FALSE values are not counted
- Returns 0 if no values are TRUE
- Can be used with WHERE clause to filter before counting
- Can be used with GROUP BY clause for grouped counts