STDDEV_SAMP function [Aggregate]

Function

Computes the standard deviation of a sample consisting of a numeric-expression, as a DOUBLE.

NoteSTDDEV_SAMP is an alias for STDDEV.

Syntax

STDDEV_SAMP ( [ ALL ] expression )

Parameters

expression The expression (commonly a column name) whose sample-based standard deviation is calculated over a set of rows.

Examples

The following statement lists the average and variance in the number of items per order in different time periods:

SELECT year( ship_date ) AS Year, quarter( ship_date )
  AS Quarter, AVG( quantity ) AS Average, 
  STDDEV_SAMP( quantity ) AS Variance 
FROM SalesOrderItems GROUP BY Year, Quarter 
  ORDER BY Year, Quarter;

Year

Quarter

Average

Variance

2000

1

25.775148

14.3218

2000

2

27.050847

15.0696

...

...

...

...

Usage

Computes the sample standard deviation of the provided value expression evaluated for each row of the group or partition (if DISTINCT was specified, then each row that remains after duplicates have been eliminated), defined as the square root of the sample variance.

NULL returns NULL for a one-element input set.

Standard deviations are computed according to the following formula, which assumes a normal distribution:

Computes the sample standard deviation of the provided value expression evaluated for each row of the group or partition if DISTINCT was specified, then each row that remains after duplicates have been eliminated, defined as the square root of the sample variance

Standards and compatibility

See also

“Analytical functions”

“STDDEV function [Aggregate]”

Chapter 2, “Using OLAP” in the System Administration Guide: Volume 2