STD Function
Description
The STD function is an alias of STDDEV_SAMP and computes the sample standard deviation of a set of numeric data. Standard deviation is a statistical measure of dispersion, used to indicate how spread out the values in a dataset are.
Parameters
expr: A numeric column or expression, which can be of typeTINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE, orDECIMAL.DISTINCT: An optional parameter. WhenDISTINCTis specified, the function computes the standard deviation of the deduplicated set. IfDISTINCTis not set, the standard deviation is computed on the set including duplicates.
Return Type
- Returns a
DOUBLEvalue representing the sample standard deviation of the dataset.
Notes
- If the input dataset contains
NULLvalues, they are excluded from computation. - The
STDfunction is fully identical toSTDDEV_SAMPand the two can be used interchangeably.
Examples
- Basic usage
- Using the DISTINCT keyword
- Using the FILTER clause to conditionally compute standard deviation
- Compute standard deviation by group
