VAR_SAMP function VAR_SAMP is an aggregate function that evaluates the sample variance of an expression over a set of rows. VAR_SAMP aggregate function

See for more information about these functions.

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

Syntax VAR_SAMP ( 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

Sample variance is calculated as follows:

[ sum(xi2) - sum(xi)2/n ]/(n-1) where n is the number of items in the population x1 ... xn are the items in the population
Example -- find the sample variance in flight time per aircraft SELECT AIRCRAFT, VAR_SAMP( flying_time ) FROM flights GROUP BY aircraft;