Collections:
STDDEV_POP() - Population Standard Deviation
How to calculate the population standard deviation of a field expression in result set groups using the STDDEV_POP() function?
✍: FYIcenter.com
STDDEV_POP(expr) is a MySQL built-in aggregate function that
calculates the population standard deviation of a field expression in result set groups.
For example:
SELECT help_category_id, STDDEV_POP(help_topic_id), COUNT(help_topic_id) FROM mysql.help_topic GROUP BY help_category_id; -- +------------------+---------------------------+----------------------+ -- | help_category_id | STDDEV_POP(help_topic_id) | COUNT(help_topic_id) | -- +------------------+---------------------------+----------------------+ -- | 1 | 0.5 | 2 | -- | 2 | 10.254954004414309 | 35 | -- | 3 | 84.70569561304855 | 59 | -- | 4 | 0.5 | 2 | -- | 5 | 1.6996731711975943 | 3 | -- ... -- +------------------+---------------------------+----------------------+ SELECT help_category_id, help_topic_id FROM mysql.help_topic WHERE help_category_id = 5; -- +------------------+---------------+ -- | help_category_id | help_topic_id | -- +------------------+---------------+ -- | 5 | 40 | -- | 5 | 43 | -- | 5 | 44 | -- +------------------+---------------+
STDDEV_POP() is also a window function, you can call it with the OVER clause to calculate the population standard deviation of the given expression in the current window. For example:
SELECT help_topic_id, help_category_id, STDDEV_POP(help_topic_id) OVER w FROM mysql.help_topic WINDOW w AS (PARTITION BY help_category_id); -- +---------------+------------------+----------------------------------+ -- | help_topic_id | help_category_id | STDDEV_POP(help_topic_id) OVER w | -- +---------------+------------------+----------------------------------+ -- | 0 | 1 | 0.5 | -- | 1 | 1 | 0.5 | -- | 2 | 2 | 10.254954004414309 | -- | 6 | 2 | 10.254954004414309 | -- | 7 | 2 | 10.254954004414309 | -- | 8 | 2 | 10.254954004414309 | -- | 9 | 2 | 10.254954004414309 | -- ... -- +---------------+------------------+----------------------------------+
Reference information of the STDDEV_POP() function:
STDDEV_POP(expr): std Returns the population standard deviation of expr (the square root of VAR_POP()). If there are no matching rows, STDDEV_POP() returns NULL. Arguments, return value and availability: expr: Required. The field expression in result set groups. std: Return value. The population standard deviation of the input expression. Available since MySQL 5.7.
Related MySQL functions:
⇒ STDDEV_SAMP() - Sample Standard Deviation
⇐ STDDEV() - Synonym for STDDEV_POP()
2023-11-18, 1142🔥, 0💬
Popular Posts:
What Is an Oracle Instance in Oracle? Every running Oracle database is associated with an Oracle ins...
How To Create a Stored Program Unit in Oracle? If you want to create a stored program unit, you can ...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...