VAR_SAMP [Aggregate]
Evaluates the sample variance for each row of the group. This is defined as the sum of squares of the difference of expression from the mean of expression divided by the number of remaining rows minus 1:
(SUM(expression*expression) - SUM(expression) *SUM(expression) / COUNT(expression)) / (COUNT(expression) -1)
Behavior Type
Syntax
VAR_SAMP ( expression )
Parameters
expression |
Any |
Related Functions
VAR_SAMP
is semantically identical to nonstandard functionVARIANCE
, which is provided for compatibility with other databases.- This aggregate function differs from analytic function
VAR_SAMP
, which computes the sample variance of the current row with respect to the group of rows within a window.
Examples
The following example returns the sample variance for each household ID in the customer
table.
=> SELECT VAR_SAMP(household_id) FROM customer_dimension; var_samp ------------------ 74848598.0106764 (1 row)