CUME_DIST() OVER ...

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

Returns the cumulative distribution: (number of rows <= current row) / (total rows).

Syntax

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

Notes

  • Returns a value between 0 (exclusive) and 1 (inclusive)
  • Requires ORDER BY clause to determine row ordering
  • PARTITION BY creates independent distribution groups

See also

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[1,2,3] AS id, ARRAY[10,20,30] AS v).TRANSFORM(SELECT CUME_DIST() OVER (ORDER BY v ASC)).UNWRAP() -- Cumulative fraction of rows at or before current value
;
Result
f1 ARRAY
[0.3333333333333333, 0.6666666666666666, 1.0]

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