MySQL VAR_POP() Function
The MySQL VAR_POP() function computes the population variance (square of the population standard deviation) for all non-null input values and returns the result.
VAR_POP() Syntax
Here is the syntax for MySQL VAR_POP() function:
VAR_POP(expr)
We usually use the VAR_POP() function like this:
SELECT VAR_POP(expr), ...
FROM table_name
[WHERE ...];
Or use the VAR_POP() function with the GROUP BY clause:
SELECT VAR_POP(expr), group_expr1, group_expr2, ...
FROM table_name
[WHERE ...]
GROUP BY group_expr1, group_expr2, ...;
Parameters
expr-
Required. A column name or expression. It accepts a numeric or binary value.
Return value
The MySQL VAR_POP() function returns the population variance (square of the population standard deviation) for all non-null input values.
Note that the VAR_POP() function only handles non-null values. That is, null values are ignored by the VAR_POP() function.
If all input values are null, the function will return NULL.
VAR_POP() Examples
To demonstrate usages of the MySQL BIT_AND() function, we simulate a temporary table using the following statement and UNION and SELECT:
SELECT 4 x
UNION
SELECT 5 x
UNION
SELECT 6 x;
+---+
| x |
+---+
| 4 |
| 5 |
| 6 |
+---+
3 rows in set (0.00 sec)The following statement uses the VAR_POP() function to calculate the population variance of all the values in the x column:
SELECT VAR_POP(x)
FROM (
SELECT 4 x
UNION
SELECT 5 x
UNION
SELECT 6 x
) t;
+--------------------+
| VAR_POP(x) |
+--------------------+
| 0.6666666666666666 |
+--------------------+