SQL STDDEV_POP function
Population standard deviation: divides by n and treats the group as the whole population.
- Category
- Aggregates
- Returns
numeric- In this category
- 21 of 52
Syntax
STDDEV_POP(x) | STDEVP(x) | STDDEV_POP(x) OVER (...)
Engine support
| Engine | Support | Notes |
|---|---|---|
| SQL Server | Different name or syntax | STDEVP is the SQL Server spelling |
| PostgreSQL | Yes | Supported under this name. |
| MySQL | Yes | Supported under this name. |
| SQLite | Not built in | not built in; use an extension or compute it manually |
| Oracle | Yes | Supported under this name. |
Examples
PostgreSQL
SELECT stddev_pop(price) FROM products WHERE category_id = 7;
SQL Server
SELECT STDEVP(price) FROM products WHERE category_id = 7;
Good to know
- One non-NULL value returns 0 (unlike STDDEV_SAMP's NULL) because there is no n-1 division.
- NULLs are excluded; the denominator is the count of present values.
- Use the sample form when your rows are a sample of something bigger; population form when the rows are everything you care about.
Questions about STDDEV_POP
STDDEV_POP vs STDDEV_SAMP?
The divisor: n versus n-1. STDDEV_POP returns 0 for a single row; STDDEV_SAMP returns NULL.
What is STDDEV_POP in SQL Server?
STDEVP.
How does it relate to variance?
It is the square root of VAR_POP.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, Oracle.
Functions your engine actually has
SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.