CONDITIONAL_CHANGE_EVENT
functionsupportedCore SQL functionsReturns a window event number for each row within a window partition when the value of the argument expr1 in the current row is different from the value of expr1 in the previous row. The window event number starts from 0 and is incremented by 1 to indicate the number of changes so far within that window.
Syntax
supportedpartialnot supportednot scored
CONDITIONAL_CHANGE_EVENT( <expr1> ) OVER ( [ PARTITION BY <expr2> ] ORDER BY <expr3> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] )
Parameters
| Name | Required | Description |
|---|---|---|
expr1 | required | This is an expression that gets compared with the expression of the previous row. |
expr2 | required | This is the optional expression to partition by. |
expr3 | required | This is the expression to order by within each partition. |
Usage notes
- The expression CONDITIONAL_CHANGE_EVENT (expr1) OVER (window_frame) is calculated as: CONDITIONAL_TRUE_EVENT( <expr1> != LAG(<expr1>) OVER(window_frame)) OVER(window_frame) For more information about CONDITIONAL_TRUE_EVENT, see CONDITIONAL_TRUE_EVENT.