w3resource

MySQL VAR_POP() function

VAR_POP() function

MySQL VAR_POP() function returns the population standard variance of an expression. Population variance is a statistical measure that quantifies the average squared deviation of values from the mean in a dataset.

This function is useful in -

  • VAR_POP() quantifies the spread or dispersion of values around the mean (average) in a dataset.
  • The population variance helps you understand the variability or dispersion of data points within the entire population.
  • When analyzing data, VAR_POP() helps assess the distribution of values and provides an indication of the typical deviation from the mean.
  • Population variance is used in inferential statistics to make inferences or predictions about the entire population based on the characteristics of the sample.
  • Population variance can use to compare the variability of different populations or datasets and assess their similarity or difference.
  • Population variance is used to assess the significance of differences between groups or populations.
  • Population variance is used to calculate confidence intervals for population parameters.

Syntax

VAR_POP(expr);

Where expr is an expression.

MySQL Version: 8.0

Example: VAR_POP() function

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

Sample table: purchase


Code:


-- This query calculates the population variance of the 'total_cost' column in the 'purchase' table.
SELECT VAR_POP(total_cost)
-- This statement selects the population variance 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 variance of the 'total_cost' values in the 'purchase' table.

  • SELECT VAR_POP(total_cost): This part of the query selects the population variance of the 'total_cost' column. Population variance measures how much the values in the dataset differ from the mean (average) of the 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 variance of the 'total_cost' values in the 'purchase' table. This value provides insight into the degree of spread or dispersion of the 'total_cost' values around the mean for the entire population represented by the 'purchase' table.

Output:

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

Previous: SUM() with group by
Next: VAR_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-var_pop().php