VARIANCE Function
Description
The VARIANCE function is an alias of VAR_SAMP and computes the sample variance of a set of numeric data. Variance is a statistical measure of data dispersion, reflecting the degree of variability in the data.
Parameters
expr: A numeric type, which can beTINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE, orDECIMAL.DISTINCT(optional): specifies that the variance should be computed on the deduplicated set. If this parameter is not set, the variance is computed on the set including duplicates.
Return Type
- Returns a
DOUBLEvalue representing the computed sample variance.
Notes
- If the input contains
NULLvalues, they are excluded from computation. - The
VARIANCEfunction is fully identical toVAR_SAMPand the two can be used interchangeably.
Examples
- Compute the sample variance including duplicates
- Compute the sample variance on deduplicated values
- Use FILTER clause to conditionally compute variance
- Compute variance by group
