CUME_DIST()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Enterprise Server
Topics on this page:
Overview
Returns the cumulative distribution of the given row.
EXAMPLES
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES
(1,3), (1,5), (8,2), (5,7), (5,6),
(10,1), (6,4), (3,9), (3,9), (7,2),
(7,5), (2,6), (9,10), (9,5), (4,8);
SELECT a, b, CUME_DIST() OVER w AS 'cume_dist'
FROM t1 WINDOW w AS (ORDER BY a, b);
+------+------+--------------+
| a | b | cume_dist |
+------+------+--------------+
| 1 | 3 | 0.0666666667 |
| 1 | 5 | 0.1333333333 |
| 2 | 6 | 0.2000000000 |
| 3 | 9 | 0.3333333333 |
| 3 | 9 | 0.3333333333 |
| 4 | 8 | 0.4000000000 |
| 5 | 6 | 0.4666666667 |
| 5 | 7 | 0.5333333333 |
| 6 | 4 | 0.6000000000 |
| 7 | 2 | 0.6666666667 |
| 7 | 5 | 0.7333333333 |
| 8 | 2 | 0.8000000000 |
| 9 | 5 | 0.8666666667 |
| 9 | 10 | 0.9333333333 |
| 10 | 1 | 1.0000000000 |
+------+------+--------------+
CHANGE HISTORY
EXTERNAL REFERENCES
Additional information on this topic may be found in the MariaDB Public Knowledge Base.