Collections:
PERCENT_RANK() - Rank Percentage of Sorted Values
How to calculate the rank percentage of the sorting field expression in the current result set window using the PERCENT_RANK() function?
✍: FYIcenter.com
PERCENT_RANK(n) is a MySQL built-in window function that calculates the rank percentage of the sorting field expression in the current result set window. For example:
SELECT help_topic_id AS tic, help_category_id AS cid, CUME_DIST() OVER w, PERCENT_RANK() OVER w FROM mysql.help_topic WINDOW w AS (ORDER BY help_category_id); -- +-----+-----+----------------------+-----------------------+ -- | tic | cid | CUME_DIST() OVER w | PERCENT_RANK() OVER w | -- +-----+-----+----------------------+-----------------------+ -- | 0 | 1 | 0.002932551319648094 | 0 | -- | 1 | 1 | 0.002932551319648094 | 0 | -- | 2 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- | 6 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- | 7 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- | 8 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- | 9 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- | 10 | 2 | 0.054252199413489736 | 0.002936857562408223 | -- ... -- +-----+-----+----------------------+-----------------------+
Reference information of the PERCENT_RANK() function:
PERCENT_RANK(): val Calculates the rank percentage of the sorting field expression in the current result set window. Arguments, return value and availability: val: Return value. The rank percentage of the sorting field. Available since MySQL 8.
Related MySQL functions:
⇒ RANK() - Vale Rank of Sorted Values
⇐ NTILE() - Dividing Window into N Tiles
2023-12-19, 230🔥, 0💬
Popular Posts:
How To Connect ASP Pages to Oracle Servers in Oracle? If you are running Windows IIS Web server and ...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To Assign Debug Privileges to a User in Oracle? In order to run SQL Developer in debug mode, the...
How to download Microsoft SQL Server 2005 Express Edition in SQL Server? Microsoft SQL Server 2005 E...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...