Function Reference

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;
stddevpopulationsample
1.1180339887498951.1180339887498951.2909944487358056

Price spread by category

MySQL 8.1
SELECT category,
	ROUND(STDDEV(price), 2) AS price_spread
FROM products
GROUP BY category;
categoryprice_spread
Food5.68
Drinks1.88
Snacks0.62
Grocery2

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.

See also