VAR_POP/VARIANCE Functions

Description

The VARIANCE function returns a variance of expression values of all rows. Only one expression is specified as a parameter. You can get the variance without duplicates by using the DISTINCT or UNIQUE keyword in front of the expression or the variance of all values by omitting the keyword or by using ALL.

The return value may be different from the actual evaluation value because it follows the type of the expression specified as a parameter.

The following is a formula that is applied to the function.

Syntax

VARIANCE( [DISTINCT | UNIQUE | ALL] expression )

Example

CREATE TABLE test_table (d double);

INSERT INTO test_table VALUES(78), (63.65), (230.54), (32), (17.2), (195.7689), (57.57);

SELECT VAR_POP(d) FROM test_table;

                var_pop(d)

==========================

    5.886658366433878e+003

 

SELECT VAR_POP(POWER(d,2)+d*2+1) FROM test_table;

  var_pop( power(d, 2)+d*2+1)

=============================

       3.983875901862495e+008

 

TRUNCATE TABLE test_table;

SELECT VAR_POP(d) FROM test_table;

                var_pop(d)

==========================

                      NULL