Skip to content

stddev()

Calculate the standard deviation from a one-dimensional statistical aggregate

Since 1.3.0

Calculate the standard deviation from the values in a statistical aggregate.

Calculate the standard deviation of a sample containing the integers from 0 to 100:

SELECT stddev(stats_agg(data))
FROM generate_series(0, 100) data;
stddev_y
--------
29.3002

The syntax is:

stddev(
summary StatsSummary1D,
[ method TEXT ]
) RETURNS DOUBLE PRECISION
NameTypeDefaultRequiredDescription
summaryStatsSummary1D-The statistical aggregate produced by a stats_agg call
methodTEXTsample-The method used for calculating the standard deviation. The two options are population and sample, which can be abbreviated to pop or samp
ColumnTypeDescription
stddevDOUBLE PRECISIONThe standard deviation of the values in the statistical aggregate