[]
        
(Showing Draft Content)

CUMEDIST

This function returns the cumulative distribution of a value within a set of values.

If the order is ascending, the number of rows with a value less than or equal to the current row's value is divided by the total number of rows within the partition. Else, it should be greater than or equal to and the range is (0,1].

To sort the rows, this function needs ORDERBY. The tied rows are identified by the combined values of the ORDERBY fields. If ORDERBY is not used, all rows are tied and return 1. It does not accept window frame definitions, such as FRAMEROWS and FRAMERANGE. It includes NULL values by default and treats them as the lowest possible values.

Syntax

CUMEDIST()

Example

// WINDOW(CUMEDIST(), ORDERBY([sold]))

city   | sold  | cume_dist
--------------------------
Paris     100     0.2
Berlin    150     0.4
Moscow    200     0.8     
Rome      200     0.8
London    300       1

// WINDOW(CUMEDIST(), ORDERBY([sold], [city]))

city   | sold  | cume_dist
--------------------------
Paris     100     0.2
Berlin    150     0.4
Moscow    200     0.6     
Rome      200     0.8
London    300       1