STDDEV_POP
Returns the population standard deviation, that is, how far the values deviate from the mean on average.
MySQL 8.1
STDDEV_POP(expr)Parameters
- exprDOUBLE
- Numeric expression
Return value
A floating-point number (DOUBLE); NULLs are ignored; 0 for a single value, NULL for an empty set
Examples
Spread of delivery time
MySQL 8.1
SELECT ROUND(AVG(delivery_time_min), 1) AS avg_minutes,
ROUND(STDDEV_POP(delivery_time_min), 1) AS spread_minutes
FROM orders;A single value
MySQL 8.1
SELECT STDDEV_POP(x) AS one_value,
STDDEV_SAMP(x) AS sample
FROM (
SELECT 5 AS x
) AS t;Details
The sum of squared deviations is divided by the number of values, so the result is slightly smaller than that of STDDEV_SAMP. It fits when the rows contain all the data, not a sample. Synonyms in MySQL are STDDEV and STD.