stddev aggregate function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the sample standard deviation calculated from the values in the group. This function is a synonym for std aggregate function.

Syntax

stddev ( [ALL | DISTINCT] expr ) [FILTER ( WHERE cond ) ]

This function can also be invoked as a window function using the OVER clause.

Arguments

  • expr: An expression that evaluates to a numeric.

  • cond: An optional Boolean expression filtering the rows used for aggregation.

Returns

A DOUBLE.

If DISTINCT is specified the function operates only on a unique set of expr values.

If any group consists of only one row, the function returns NULL for that group.

Examples

> SELECT stddev(col) FROM VALUES (1), (2), (3), (3) AS tab(col);
 0.9574271077563381

> SELECT stddev(DISTINCT col) FROM VALUES (1), (2), (3), (3) AS tab(col);
 1.0