Skip to main content

CUME_DIST() (SQL)

A window function that assigns the cumulative distribution value for all rows within the specified window frame.

Synopsis

CUME_DIST()

Description

CUME_DIST() assigns the cumulative distribution for all rows. A cumulative distribution describes the probability of a random variable being at or less than a certain value; this distribution is calculated by counting the rows with values less than or equal to the current row's value and dividing that count by the total number of rows in the window. The column name that the cumulative distribution is computed on is specified in the ORDER BY clause.

Examples

The following example returns the cumulative distribution of salaries for each employee within each department:

SELECT CUME_DIST() OVER (PARTITION BY Department ORDER BY Salary) FROM Company.Employee

See Also

FeedbackOpens in a new tab