SUM() OVER ...

All functions > WINDOW FUNCTION > SUM() OVER ...

Returns the sum of values in the window frame.

Syntax

SUM(expr) OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])

Notes

  • Calculates sum over a window of rows
  • Useful for running totals and cumulative sums
  • Returns same type as input expression
  • NULL values are ignored in the calculation

See also

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[1,2,3] AS id, ARRAY[30,10,20] AS v).TRANSFORM(SELECT SUM(v) OVER (ORDER BY id ASC)).UNWRAP() -- Running sum (default frame to current row; v permuted so totals differ from v)
;
Result
f1 ARRAY
[30, 40, 60]

Last update at: 2026/05/26 17:22:09