VARIANCE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Data metric functionsAggregate functionsWindow function syntax and usage

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

Syntax

supportedpartialnot supportednot scored

Aggregate function

VARIANCE( [ DISTINCT ] <expr1> )

Window function

VARIANCE( [ DISTINCT ] <expr1> ) OVER (
                                      [ PARTITION BY <expr2> ]
                                      [ ORDER BY <expr3> [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] [ <window_frame> ] ]
                                      )

Parameters

NameRequiredDescription
expr1requiredThe expr1 should evaluate to one of the numeric data types.
expr2requiredThis is the expression to partition by.
expr3requiredThis 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