Skip to main content
Aggregate · Window
NULL values are ignored; all-NULL input 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

Arguments

Aggregate and window

Returns

  • Type: DOUBLE for integer inputs; the input’s effective FLOAT, DOUBLE, or DECIMAL type for floating-point and decimal inputs
  • NULL behavior: NULL values are ignored; all-NULL input yields NULL.
  • Empty input: Returns NULL on empty input.

Properties

Usage notes

  • MEDIAN calculates the continuous percentile at 0.5.
  • MEDIAN calculates percentile 0.5 and returns one value. It does not accept an array of percentile fractions.
  • 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.
  • In grouped aggregation, DISTINCT removes duplicate input values before calculating the median.

Examples

Basic example

Groups with different numbers of values

NULL values are excluded from the calculation. Results are rounded to six decimal places where needed.

Limitations

  • Sliding ROWS frames are supported for the window syntax shown above. RANGE frames with numeric or time offsets are not supported.
  • Floating-point and decimal results can keep their effective input type, even when query tools report DOUBLE.
  • DISTINCT in a window call currently has no effect: duplicate rows still contribute to the result. Use grouped DISTINCT aggregation when duplicate removal is required.
Last modified on October 15, 2026