STDDEV Function [Aggregate]

Returns the standard deviation of a set of numbers.

Syntax

STDDEV ( [ ALL ] expression )

Parameters

Parameter

Description

expression

Any numeric data type (FLOAT, REAL, or DOUBLE precision) expression.

Returns

DOUBLE

Examples

Given this data:
SELECT Salary FROM Employees WHERE DepartmentID = 300

      Salary

 51432.000

 57090.000

 42300.000

   43700.00

  36500.000

138948.000

  31200.000

    58930.00

    75400.00

The following statement returns the value 32617.8446712838471:

SELECT STDDEV ( Salary ) FROM Employees
WHERE DepartmentID = 300
Given this data:
SELECT UnitPrice FROM Products WHERE Name = 'Tee Shirt'

Name

UnitPrice

Tee Shirt

            9.00

Tee Shirt

          14.00

Tee Shirt

          14.00

The following statement returns the value 2.88675134594813049:

SELECT STDDEV ( UnitPrice ) FROM Products
WHERE Name = 'Tee Shirt'

Usage

The formula used to calculate STDDEV is:


The formula used by the STDDEV function to calculate standard deviation is stddev equals the square root of variance

STDDEV returns a result of data type DOUBLE precision floating-point. If applied to the empty set, the result is NULL, which returns NULL for a one-element input set.

STDDEV does not support the keyword DISTINCT. A syntax error is returned if you use DISTINCT with STDDEV.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Related concepts
Windowing Aggregate Function Usage
Related reference
STDDEV_SAMP Function [Aggregate]
VARIANCE Function [Aggregate]