VARIANCE
Calculate population variance. This function is a synonym for VAR_POP() and returns the variance of a set of values.
Syntax
VARIANCE(expr)Description
Returns the population standard variance of expr. This is an extension to standard SQL. The standard SQL function VAR_POP() can be used instead.
Variance is calculated by
working out the mean for the set;
for each number, subtracting the mean and squaring the result;
calculating the average of the resulting differences.
It is an aggregate function, and so can be used with the GROUP BY clause.
VARIANCE() can be used as a window function.
VARIANCE() returns NULL if there were no matching rows.
Examples
CREATE TABLE v(i tinyint);
INSERT INTO v VALUES(101),(99);
SELECT VARIANCE(i) FROM v;
+-------------+
| VARIANCE(i) |
+-------------+
| 1.0000 |
+-------------+
INSERT INTO v VALUES(120),(80);
SELECT VARIANCE(i) FROM v;
+-------------+
| VARIANCE(i) |
+-------------+
| 200.5000 |
+-------------+As an aggregate function:
As a window function:
See Also
VAR_POP (equivalent, standard SQL)
STDDEV_POP (population standard deviation)
STDDEV_SAMP (sample standard deviation)
This page is licensed: GPLv2, originally from fill_help_tables.sql
Last updated
Was this helpful?

