CUME_DIST
CUME_DIST calculates the cumulative distribution of a value in a group of values.
Syntax
CUME_DIST () OVER ( [ PARTITION BY expression [, ...] ]
ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } [, ...] )
Remarks
• CUME_DIST can be rewritten using COUNT. For example:
CUME_DIST() OVER (partition_by_order_by)
This is equivalent to either of the following COUNT expressions:
COUNT (*) OVER ( partition_by_order_by RANGE UNBOUNDED PRECEDING )
COUNT (*) OVER ( partition_by_order_by RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) )
• The range of values returned by CUME_DIST is (0, 1]; that is, greater than zero, and less than or equal to 1.
• Tie values always evaluate to the same cumulative distribution value.
• PARTITION BY is optional.
• ORDER BY is required.
• The window clause is not allowed.