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

ParameterTypeRequiredDescription
exprBOOLEANYesThe 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

Examples

Last update at: 2025/10/13 10:23:46