.-ALL------. >>-+-VAR_SAMP------+--(--+----------+--numeric-expression--)--->< '-VARIANCE_SAMP-' '-DISTINCT-'
The VAR_SAMP function returns the sample variance (/n-1) of a set of numbers. The formula used to calculate the sample variance is:
VAR_SAMP = (SUM(X**2) - ((SUM(X)**2) / (COUNT(*)))) / (COUNT(*) - 1)
The data type of the result is double-precision floating point.
The function is applied to the set of values derived from the argument values by the elimination of null values. If DISTINCT is specified, duplicate values are eliminated.
The result can be null. If the function is applied to the empty set or a set with only one row, the result is a null value. Otherwise, the result is the variance of the values in the set.
The order in which the values are added is undefined, but every intermediate result must be within the range of the result data type.
Syntax alternatives: VAR_SAMP should be used for conformance to the SQL 1999 standard.
SELECT VAR_SAMP(SALARY) INTO :VARNCE FROM EMPLOYEE WHERE WORKDEPT = 'A00';Results in VARNCE being set to approximately 1 186 437 500.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.