Categories:

Aggregate Functions (General) , Window Functions

STDDEV

Returns the sample standard deviation (square root of sample variance) of non-NULL values. If all records inside a group are NULL, returns NULL.

Alias for STDDEV_SAMP.

Syntax

STDDEV([DISTINCT] <expr>)

Arguments

expr

An expression that evaluates to a numeric value.

Usage Notes

  • For single-record inputs, STDDEV_SAMP and STDDEV both return NULL. This is different from the Oracle behavior, where STDDEV_SAMP returns NULL for a single record and STDDEV returns 0.

Examples

This shows the standard deviation of a small sample of integers:

CREATE TABLE devious (i INTEGER);
INSERT INTO devious (i) VALUES
    (6),
   (10),
   (14)
   ;

SELECT STDDEV(i) FROM devious;

Output:

+----------+
| STDDEV() |
|----------|
|        4 |
+----------+