stddev_pop

Returns the population standard deviation of non-NULL values.

Syntax

stddev_pop(<expr>)

Arguments

ArgumentTypeDescription
<expr>int, uint, or floatInput value.

Returns

Returns float. Ignores NULL values. Returns NULL for no non-NULL values and 0.0 for one non-NULL value.

Examples

Compare request latency across channels, treating these rows as all requests in the reporting period:

VALUES
    ('web', 100.0), ('web', 120.0), ('web', 140.0),
    ('mobile', 60.0), ('mobile', 120.0), ('mobile', 180.0)
SELECT $0 AS channel, $1 AS latency_ms
GROUP BY channel
AGGREGATE avg(latency_ms) AS avg_ms, stddev_pop(latency_ms) AS stddev_ms
SELECT channel, avg_ms, round(stddev_ms * 100.0) / 100.0 AS stddev_ms
ORDER BY channel
+---------+--------+-----------+
| channel | avg_ms | stddev_ms |
+---------+--------+-----------+
| mobile  | 120.0  | 48.99     |
| web     | 120.0  | 16.33     |
+---------+--------+-----------+

Both channels have the same mean, but mobile durations are more spread out. The population standard deviation is measured in ms; results are rounded to two decimal places.