COUNT_IF
functionsupportedCore SQL functionsReturns 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
| Name | Required | Description |
|---|---|---|
condition | required | The condition is an expression that should evaluate to a BOOLEAN value (True, False, or NULL) |
expr1 | required | The column to partition on, if you want the result to be split into multiple windows. |
expr2 | required | The 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
- When this function is called as a window function with an ORDER BY clause, you must specify a window frame. If you do not specify a window frame, the following default frame is used: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW For more information about window frames, including syntax, usage notes, and examples, see Window function syntax and usage.