w3resource

MySQL STDDEV_POP() function

STDDEV_POP() function

MySQL STDDEV_POP() function returns the population standard deviation of an expression ( the square root of VAR_POP()). Statistically, the population standard deviation quantifies how much variation there is in a dataset.

It returns NULL if no matching row is found.

This function is useful in -

  • The primary purpose of the STDDEV_POP() function is to accurately calculate the population standard deviation.
  • STDDEV_POP() quantifies the spread or dispersion of values around the mean (average) in a dataset.
  • The population standard deviation helps you understand the variability or consistency of data points within the entire population.
  • Population standard deviation is used to calculate confidence intervals for population parameters.
  • You can use population standard deviation to compare the variability of different populations or datasets and assess their similarity or difference.
  • In finance and risk analysis, population standard deviation is used to measure the volatility or risk associated with investment returns or financial instruments.

Syntax:

STDDEV_POP(expr);

Where expr is an expression.

MySQL Version: 8.0

Example: MySQL STDDEV_POP() function

The following statement returns the standard deviation of 'total_cost' from purchase table.

Sample table: purchase


Code:


-- This query calculates the population standard deviation of the 'total_cost' column in the 'purchase' table.
SELECT STDDEV_POP(total_cost)   
-- This statement selects the population standard deviation of the 'total_cost' column.
FROM purchase;
-- This part of the query specifies the table from which data is being retrieved, which is 'purchase'.

Explanation:

  • The purpose of this SQL query is to compute the population standard deviation of the 'total_cost' values in the 'purchase' table.

  • SELECT STDDEV_POP(total_cost): This part of the query selects the population standard deviation of the 'total_cost' column. Population standard deviation is a statistical measure of the amount of variation or dispersion in a population.

  • FROM purchase: This part specifies the table from which the data is being selected, which is the 'purchase' table.

  • The query will return a single value, which is the population standard deviation of the 'total_cost' values in the 'purchase' table. This value provides insight into the spread or dispersion of the 'total_cost' values in the entire population represented by the 'purchase' table.

Output:

mysql> SELECT STDDEV_POP(total_cost)   
    -> FROM purchase;
+------------------------+
| STDDEV_POP(total_cost) |
+------------------------+
|             315.392172 | 
+------------------------+
1 row in set (0.00 sec)

Previous: STD()
Next: STDDEV_SAMP()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-stddev_pop().php