this is an aggregate function. As such, it accepts a single operand which can wither be a scalar, in which case it will operate in turn on each item of the group, or an array or a vector in which case it will operate on each value in sequence and return the result (in practice, this process is delayed until the group is submitted for performance reasons)

User can choose to skip over NULL values or to include them in the computation with one of the modifiers SKIP NULLS to skip NULL values (the default) and KEEP NULLS to include them.

In the first case the result will still be NULL if all input values are NULL, and in the last case any NULL value will make the result NULL.

The other modifier tells whether the state used to compute the aggregate must be local (each group has its own independent state) or global (all groups share a single state). In general when using a GROUP-BY clause the former behavior is intended, and it is thus the default when an explicit GROUP-BY clause is present. Otherwise, the default is to use only one global state.

One can choose between those two with the modifier LOCALLY to force a group-wise state and GLOBALLY to force a global state.

This choice of the state lifespan is only meaningful when the operation is applied to a single scalar value, since the state required to compute the end result over a literal array or vector lives only as long as that computation.

Syntax

EVERY …num-expr… [ SLIDING | TUMBLING ] …expr…

EVERY(…num-expr…, …bool-expr…, …expr…)

Typing

num, BOOL, t -> t?

Description

EVERY is similar to ONE OUT OF but based on time rather than number of inputs.

If TUMBLING is selected (or the second operand of the functional syntax is true) then time is divided into windows of the given duration (aligned such that timestamp modulo duration is NULL), and the first value of each new such window is selected (and all others are NULL), whereas if SLIDING is selected then the next value after at least the selected duration is selected (regardless of time alignment).

Limitations

The period must be a constant.

See Also

Nullifies all values but one out of N Group past values based on time