COUNT_IF

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Returns the number of records that satisfy a condition or NULL if no records satisfy the condition.

Syntax

supportedpartialnot supportednot scored

Aggregate function

COUNT_IF( <condition> )

Window function

COUNT_IF( <condition> )
    OVER ( [ PARTITION BY <expr1> ] [ ORDER BY <expr2> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] [ <window_frame> ] ] )

Parameters

NameRequiredDescription
conditionrequiredThe condition is an expression that should evaluate to a BOOLEAN value (True, False, or NULL)
expr1requiredThe column to partition on, if you want the result to be split into multiple windows.
expr2requiredThe column to order each window on. Note that this is separate from the ORDER BY clause that sorts the final result set.

Returns

If the function does not return NULL, the data type of the returned value is NUMBER.

Usage notes

See also

Referenced by