VAR_SAMP Function
Description
The VAR_SAMP function calculates the sample variance of a set of numeric data. Variance is a statistical measure of data dispersion that reflects the magnitude of data volatility. By calculating variance, we can understand the range and trends of data fluctuations.
Parameter Description
expr: Numeric type, can beTINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE, orDECIMAL.DISTINCT(optional): Indicates the calculation of the variance of the set after deduplication. If this parameter is not set, the variance of the set including duplicate values is calculated.
Return Result
- Returns a
DOUBLEtype value representing the calculated sample variance. - If the input parameters contain
NULLvalues, theNULLvalues are not included in the calculation.
Usage Examples
- Calculate the sample variance including duplicate values:
- Calculate the sample variance after deduplication:
- Use the FILTER clause to conditionally calculate the sample variance:
- Combine the FILTER clause and DISTINCT to calculate the conditional sample variance:
