Skip to main content
Aggregate · Window
Pairs with either value NULL are excluded. Fewer than two valid pairs yields NULL.

Syntax

A window function keeps each input row and adds a result for that row. PARTITION BY groups rows with matching values; without it, all input rows form one group.

Aggregate

Window

  • Use a frame that includes all rows in the group or starts at the first row (UNBOUNDED PRECEDING). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.

Arguments

Aggregate and window

Returns

  • Type: DOUBLE
  • NULL behavior: Pairs with either value NULL are excluded. Fewer than two valid pairs yields NULL.
  • Empty input: Returns NULL on empty input.

Properties

Usage notes

  • Inputs are converted to DOUBLE. Floating-point rounding can cause small differences in the last digits of the result.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
  • Supports DISTINCT: Adding DISTINCT does not remove duplicate input values.

Examples

Basic example

A negative relationship and a missing pair

The row with a NULL value is excluded from the calculation.

Limitations

  • Use all rows in the group or a frame starting with UNBOUNDED PRECEDING. Other starting boundaries are outside the forms covered here.
  • DISTINCT does not remove duplicate input values in grouped calls. Removing duplicates can change the result, so remove duplicates from the input separately when needed.
Last modified on October 15, 2026