VAR_SAMP

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate 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. Variance measures how far a set of values is spread out from their mean. The sample variance is the sum of the squared differences between each value and the mean of the values, divided by the number of values minus one (n - 1). Use the sample variance when the values are a sample drawn from a larger population. When the values are the entire population, use VAR_POP, which divides by the number of values (n).

Syntax

supportedpartialnot supportednot scored

Aggregate function

VAR_SAMP( [DISTINCT] <expr1> )

Window function

VAR_SAMP( <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