VAR_POP
Computes the population variance of all non-NULL
numeric values produced by an expression. The population variance measures the average of the squared differences from the population mean, indicating how spread out the values are within the entire population. For information about the sample variance, which measures how spread out the values are within a sample, see VAR_SAMP.
Syntax
VAR_POP(<expression>)
Parameters
Parameter | Description | Supported input types |
---|---|---|
<expression> | An expression producing numeric values for which to calculate the population variance. | REAL , DOUBLE PRECISION |
Return Type
VAR_POP
returns a result of type DOUBLE PRECISION
.
Special cases
- If there are no non-
NULL
input values, the result isNULL
. - If the input contains an
Inf
orNaN
value, the result will beNaN
.
Example
The following code creates an exams
table with a grade
column of type DOUBLE PRECISION
, and inserts five grade values into it:
CREATE TABLE exams (grade DOUBLE PRECISION);
INSERT INTO exams VALUES (4.0), (3.7), (3.3), (2.7), (2.7);
The following code calculates the population variance of the grade values from the exams
table, rounds the result to three decimal places, and returns it as variance
:
SELECT ROUND(VAR_POP(grade), 3) as variance from exams;
Returns The previous code returns the following result:
variance (DOUBLE PRECISION) |
---|
0.274 |