CONDITIONAL_TRUE_EVENT

functionsupportedCore SQL functions

docs.snowflake.com ↗

Window functions

Returns a window event number for each row within a window partition based on the result of the boolean argument expr1. The number starts from 0 and is incremented by 1 for each row on which the expr1 evaluates to true. One use of this function is to sessionize window partitions. For example, in click stream data, it can be used to determine whether a user has started a new session by checking whether the last event was longer ago than a threshold.

Syntax

supportedpartialnot supportednot scored

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

Parameters

NameRequiredDescription
expr1requiredThis is a boolean expression that changes the window event number value when it evaluates true.
expr2requiredThis is the optional expression to partition by.
expr3requiredThis is the expression to order by within each partition.

Usage notes