STDDEV
A synonym for STDDEV_POP: returns the population standard deviation.
MySQL 8.1
STDDEV(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
STDDEV equals STDDEV_POP
MySQL 8.1
SELECT STDDEV(x) AS stddev,
STDDEV_POP(x) AS population,
STDDEV_SAMP(x) AS sample
FROM (
SELECT 1 AS x
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
) AS t;Price spread by category
MySQL 8.1
SELECT category,
ROUND(STDDEV(price), 2) AS price_spread
FROM products
GROUP BY category;Details
In PostgreSQL, STDDEV calculates the sample deviation, like STDDEV_SAMP, so the same query gives different numbers in the two DBMSs. To make the result independent of the DBMS, write STDDEV_POP or STDDEV_SAMP explicitly.