STDDEV()
Returns the standard deviation of a set of values, measuring spread around the mean.
Description
STDDEV is an aggregate function that computes the standard deviation of a set
of numbers — how spread out the values are from their average. A low standard
deviation means values cluster tightly around the mean; a high one means they're
scattered. It's a core statistic for understanding variability in data like
salaries or test scores.
Syntax
STDDEV(expression)
STDDEV_SAMP(expression)
STDDEV_POP(expression)Parameters
| Name | Description | Optional |
|---|---|---|
| expression | A numeric column or expression. | No |
Return Type
Returns a DOUBLE (floating-point) value. With fewer than two non-NULL values
it typically returns NULL.
Examples
Loading database engine...
Loading database engine...
Sample vs population
STDDEV usually means the sample version (STDDEV_SAMP). Use STDDEV_POP
when your data is the entire population, not a sample.
Common Mistakes
- Confusing sample and population. They differ by a small denominator adjustment; pick the one matching your data.
- Applying it to non-numeric data.
STDDEVneeds numbers; text columns error or coerce unexpectedly. - Ignoring NULLs. NULL values are ignored, which can change the result if you expected them to count as zero.
Related Functions
See also: AVG, VARIANCE.