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, 930🔥, 0💬
Popular Posts:
How to download and install Microsoft SQL Server Management Studio Express in SQL Server? Microsoft ...
What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema in Oracle? For a us...
What Is Oracle in Oracle? Oracle is a company. Oracle is also a database server, which manages data ...
How to download and install the scaled-down database AdventureWorksLT in SQL Server? If you want to ...
What To Do If the StartDB.bat Failed to Start the XE Instance in Oracle? If StartDB.bat failed to st...