Aggregates Aggregate

count_if()

Counts the total number of TRUE values for a boolean column

Arguments & returns

count_if(arg)

Aggregate
Overload link arg Returns
#01 BOOLEAN HUGEINT

Example

count_if example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example with sample data · Run to view results.

In other engines

BigQuerycountif()

SELECT COUNTIF(x)
In DuckDB
SELECT COUNT_IF(x)

SQLGlot example ↗

Snowflakecount_if()

SELECT COUNT_IF(x > 1) FROM t
In DuckDB
SELECT COUNT_IF((x > 1) IS TRUE) FROM t

SQLGlot example ↗