Window
CUME_DIST()
Overview
The CUME_DIST()
function is a window function used to calculate the cumulative distribution of a value within a set of values. This function returns a value between 0 and 1, representing a relative position of a row within a partition or result set.
Syntax
The syntax for this function is as follows:
Parameters
- (): this function takes no arguments but parentheses is required
Example
For the needs of this section we will use a simplified version of the film
table from the Pagila database, containing only the title
, length
and rating
columns.
The query below uses the CUME_DIST()
function to calculate the cumulative distribution of film lengths:
When executing the code above, we will get the following output: