Collections:
CUME_DIST() - Cumulative Distribution of Sorted Values
How to calculate the cumulative distribution of the sorting field expression in the current result set window using the CUME_DIST() function?
✍: FYIcenter.com
CUME_DIST() is a MySQL built-in window function that calculates the cumulative distribution of the sorting field expression in the current result set window. For example:
SELECT help_topic_id, help_category_id, CUME_DIST() OVER w FROM mysql.help_topic WINDOW w AS (ORDER BY help_category_id); -- +---------------+------------------+----------------------+ -- | help_topic_id | help_category_id | CUME_DIST() OVER w | -- +---------------+------------------+----------------------+ -- | 0 | 1 | 0.002932551319648094 | -- | 1 | 1 | 0.002932551319648094 | -- | 2 | 2 | 0.054252199413489736 | -- | 6 | 2 | 0.054252199413489736 | -- | 7 | 2 | 0.054252199413489736 | -- | 8 | 2 | 0.054252199413489736 | -- | 9 | 2 | 0.054252199413489736 | -- ... -- +---------------+------------------+----------------------+
Reference information of the CUME_DIST() function:
CUME_DIST(): val Returns the cumulative distribution of the sorting field expression in the current result set window. Arguments, return value and availability: val: Return value. The cumulative distribution of the sorting field. Available since MySQL 8.
Related MySQL functions:
⇒ DENSE_RANK() - Density Rank of Sorted Values
⇐ MySQL Functions on Result Set Windows
2024-05-15, 559🔥, 0💬
Popular Posts:
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Disable a Login Name in SQL Server? If you want temporarily disable a login name, you can use...
How to execute statements in loops in SQL Server Transact-SQL? How to use WHILE ... loops? You can u...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...