Skip to content
SQLSimplified
aggregate

VARIANCE()

Returns the variance (squared spread) of a set of numeric values.

Description

VARIANCE is an aggregate function that measures how far a set of numbers spreads from their mean, squared. It's the square of the standard deviation and is widely used in statistics. A larger variance means the values are more dispersed.

Syntax

VARIANCE(expression)
VAR_SAMP(expression)
VAR_POP(expression)

Parameters

NameDescriptionOptional
expressionA numeric column or expression.No

Return Type

Returns a DOUBLE. With fewer than two non-NULL values it typically returns NULL.

Examples

Employees & Departments

Loading database engine...

Employees & Departments

Loading database engine...

Variance vs STDDEV

STDDEV is just the square root of VARIANCE. Use variance when you need the squared unit, or standard deviation for an interpretable, same-unit measure.

Common Mistakes

  • Mixing sample and population. VAR_SAMP vs VAR_POP differ slightly; VARIANCE usually means the sample form.
  • Interpreting the unit. Variance is in squared units, which can be hard to reason about — prefer STDDEV for readability.
  • Non-numeric input. Variance requires numbers; text columns will error.

See also: AVG, STDDEV.

Search

Search lessons, functions, examples, and practice problems