CUME_DIST()

Overview

Returns the cumulative distribution of the given row.

See also: Functions in 10.6 ES, in 10.6 CS, in 10.5 ES, in 10.5 CS, in 10.4 ES, in 10.4 CS, in 10.3 ES, in 10.3 CS, in 10.2 ES, and in 10.2 CS

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

Release Series

History

10.6 Enterprise

  • Present starting in MariaDB Enterprise Server 10.6.4-1.

10.6 Community

  • Present starting in MariaDB Community Server 10.6.0.

10.5 Enterprise

  • Present starting in MariaDB Enterprise Server 10.5.3-1.

10.5 Community

  • Present starting in MariaDB Community Server 10.5.0.

10.4 Enterprise

  • Present starting in MariaDB Enterprise Server 10.4.6-1.

10.4 Community

  • Present starting in MariaDB Community Server 10.4.0.

10.3 Enterprise

  • Present starting in MariaDB Enterprise Server 10.3.16-1.

10.3 Community

  • Present starting in MariaDB Community Server 10.3.0.

10.2 Enterprise

  • Present starting in MariaDB Enterprise Server 10.2.25-1.

10.2 Community

  • Present starting in MariaDB Community Server 10.2.0.

EXTERNAL REFERENCES