Skip to main content
Returns the cumulative distribution of the current row within its partition. The result is the number of rows that precede or are peers with the current row, divided by the total number of rows in the partition. Values are always in the range (0, 1]. For more information on usage, please refer to Window Functions.

Syntax

Parameters

ParameterDescriptionSupported input types
<partition_by>An expression used for the PARTITION BY clause.Any
<order_by>An expression used for the ORDER BY clause.Any

Return Type

DOUBLE PRECISION

Remarks

  • CUME_DIST takes no arguments.
  • When no ORDER BY clause is specified, all rows within the partition are considered peers and CUME_DIST returns 1 for every row.
  • Unlike PERCENT_RANK, the minimum value of CUME_DIST is 1/N (not 0), where N is the partition size.
  • This function respects NULL values, and results will be ordered with default null ordering NULLS LAST unless otherwise specified in the ORDER BY clause.

Example

The following example ranks each level by maxpoints within its leveltype, showing what fraction of levels in the same type have a maxpoints value less than or equal to the current row:
level int nullleveltype text nullmaxpoints int nullcd double
6Drift800.5
9Drift2501
1FastestLap200.25
3FastestLap400.5
7FastestLap700.75
8FastestLap1001
2FirstToComplete300.25
4FirstToComplete1000.5
5FirstToComplete1500.75
10FirstToComplete5001

Rows: 10Execution time: 8.19ms