count_if
Count rows whose condition is SQL true; skip false and NULL conditions.
Syntax
text
count_if(condition)Arguments
condition: one SQL expression per row. Nonzero numeric truth selects the row; ordinary SQL truth conversion applies.
Returned value
Nonnegative signed INTEGER count; 0 for empty input or no true conditions, saturating at 9223372036854775807.
Examples
sql
CREATE TABLE orders (amount INTEGER);
INSERT INTO orders VALUES (1),(NULL),(2);sql
SELECT count_if(amount > 1) FROM orders FORMAT csv;text
1