Categories:

Aggregate Functions (General) , Window Functions

VARIANCE , VARIANCE_SAMP

Returns the sample variance of non-NULL records in a group. If all records inside a group are NULL, a NULL is returned.

These functions are synonymous and are aliases for VAR_SAMP.

Syntax

VARIANCE( [ DISTINCT ] x )

VARIANCE_SAMP( [ DISTINCT ] x )

Usage Notes

  • For single-record inputs, VARIANCE, VARIANCE_SAMP, and VAR_SAMP all return NULL. This is different from the Oracle behavior, where VAR_SAMP returns NULL for a single record and VARIANCE returns 0.

Examples

See the example(s) in VAR_SAMP.