STDDEV_POP
This function returns the standard deviation of expr
within a window or group of rows. Therefore, it has the following formula:
Syntax
stddev_pop::=
Usage Notes
- With
DISTINCT
, the function considers duplicate values ofexpr
only once. It considers all occurrences withALL
. If the function contains neitherALL
norDISTINCT
, the default isALL
. - If a window or group has only one row, then the result of this function is 0.
Examples
Aggregate Function
Result
DEPARTMENT | STDDEV_POP |
ACCOUNTS | 9486.833 |
HR | 12437.343 |
Analytic Function
SELECT
id, department, hire_date, current_salary,
STDDEV_POP(current_salary) OVER (PARTITION BY department ORDER BY hire_date) STDDEV_POP
FROM employee_table ORDER BY department, hire_date;
Result
ID | DEPARTMENT | HIRE_DATE | CURRENT_SALARY | STDDEV_POP |
2005 | ACCOUNTS | 2013-01-01 | 80000 | 0 |
2003 | ACCOUNTS | 2015-07-01 | 80000 | 0 |
2002 | ACCOUNTS | 2017-01-01 | 65000 | 6495.1905 |
2004 | ACCOUNTS | 2017-01-01 | 70000 | 6495.1905 |
2001 | ACCOUNTS | 2018-07-01 | 55000 | 9486.833 |
1003 | HR | 2014-01-01 | 90000 | 0 |
1002 | HR | 2016-01-01 | 70000 | 9428.0904 |
1004 | HR | 2016-01-01 | 70000 | 9428.0904 |
1001 | HR | 2018-01-01 | 55000 | 12437.343 |