VAR_POP function

VAR_POP is an aggregate function that evaluates the population variance of an expression over a set of rows.

See Aggregates (set functions) for more information about these functions.

VAR_POP is allowed only on expressions that evaluate to numeric data types.

Syntax

VAR_POP ( expression )

The expression can contain multiple column references or expressions, but it cannot contain another aggregate or subquery. It must evaluate to a built-in numeric data type. If an expression evaluates to NULL, the aggregate skips that value.

The resulting data type is DOUBLE (it might overflow).

Formula

Population variance is calculated as follows:


sum(xi2)/n - m2

where

n is the number of items in the population
m is the population average
x1 ... xn are the items in the population

Example

-- find the variance in flight time per aircraft
SELECT AIRCRAFT, VAR_POP( flying_time )
FROM flights GROUP BY aircraft;