var_samp

Computes the sample variance over each aggregate.

Syntax

var_samp([DISTINCT] arith_expr)

Parameters

arith_expr The arithmetic expression on which the sample variance is to be computed.

Description

This function computes the sample variance for each aggregate from the value of arith_expr for each row in the aggregate. The denominator used in the sample variance calculation is the one less than the number of rows contained in each aggregate.

If distinct is specified, duplicate values are not included in the computation.

Example

open nsfawards;

select orgid, count(*), var_samp(amount) from nsforg natural join award 
    group by 1 having count(*) >= 5000;

orgid      count(*)  var_samp(amount)
CHE            5702  332883647523.011
DMI            6526  68732915230.1978
DMR            5381  5872525683130.36
DMS            9910  252926145875.085
DUE            8810  168043092514.989
EAR            7256  2633613548544.64
IBN            5438  66045677950.6148
INT            5954   361861403180.72
OCE            5998  15840348623471.1
SES            5944  130155169863.578