Aggregate · Window
NULLs are ignored; all-NULL groups and frames return 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
- RANGE frames with a numeric or time offset are not supported. Use unique ORDER BY values for calculations that advance one row at a time. DISTINCT is not supported in these window forms.
Arguments
Aggregate and window
Returns
- Type: Same SQL type as value
- NULL behavior: NULLs are ignored; all-NULL groups and frames return NULL.
- Empty input: Returns NULL on an empty global aggregate or empty frame.
Properties
Usage notes
- 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.
- Query tools may report a DECIMAL result as DOUBLE or a TIME result as INTEGER. The returned value still keeps its decimal precision and scale, or its time type. A reported type does not convert the value.
- Use DISTINCT in grouped aggregation only. It does not provide duplicate removal in a window call.
Examples
Sample data
Integer values
Ignore NULLs
Aggregate the sample values
One result per group, including an all-NULL group
Window over all rows in each group
Running window
Sliding window with one preceding row
Only NULL values
Empty filtered sample
Last modified on October 15, 2026