Skip to content
SQLSimplified
aggregate

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

NameDescriptionOptional
expressionA 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

Employees & Departments

Loading database engine...

Employees & Departments

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. STDDEV needs 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.

See also: AVG, VARIANCE.

Search

Search lessons, functions, examples, and practice problems