VARIANCE , VARIANCE_SAMP | Snowflake Documentation (original) (raw)

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

Aliases:

VAR_SAMP

Syntax

Aggregate function

VARIANCE( [ DISTINCT ] )

Window function

VARIANCE( [ DISTINCT ] ) OVER ( [ PARTITION BY ] [ ORDER BY [ ASC | DESC ] [ ] ] )

For detailed _windowframe_ syntax, see Window function syntax and usage.

Arguments

_expr1_

The _expr1_ should evaluate to one of the numeric data types.

_expr2_

This is the expression to partition by.

_expr3_

This is the expression to order by within each partition.

Returns

The data type of the returned value is NUMBER(<precision>, <scale>). The scale depends upon the values being processed.

Usage notes

Examples

For examples, see VAR_SAMP.