Skip to main content
Version: 3.2

variance,var_pop,variance_pop

Description

Returns the population variance of an expression. Since v2.5.10, this function can also be used as a window function.

Syntax

VARIANCE(expr)

Parameters

expr: the expression. If it is a table column, it must evaluate to TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, or DECIMAL.

Return value

Returns a DOUBLE value.

Examples

MySQL > select var_pop(i_current_price), i_rec_start_date from item group by i_rec_start_date;
+--------------------------+------------------+
| var_pop(i_current_price) | i_rec_start_date |
+--------------------------+------------------+
| 314.96177792808226 | 1997-10-27 |
| 463.73633459357285 | NULL |
| 302.02102643609123 | 1999-10-28 |
| 337.9318386924913 | 2000-10-27 |
| 333.80931439318346 | 2001-10-27 |
+--------------------------+------------------+

MySQL > select variance(i_current_price), i_rec_start_date from item group by i_rec_start_date;
+---------------------------+------------------+
| variance(i_current_price) | i_rec_start_date |
+---------------------------+------------------+
| 314.96177792808226 | 1997-10-27 |
| 463.7363345935729 | NULL |
| 302.02102643609123 | 1999-10-28 |
| 337.9318386924912 | 2000-10-27 |
| 333.80931439318346 | 2001-10-27 |
+---------------------------+------------------+

keyword

VARIANCE,VAR_POP,VARIANCE_POP