SQL Standard Deviation or SQL STDDEV Function returns the standard deviation of available records. Oracle Standard Deviation or Oracle STDDEV Function can accept a column name or formula as parameter for Standard Deviation calculation.
SQL Standard Deviation Function Syntax
SELECT STDDEV(numeric column / formula) FROM table_name WHERE conditions;
SQL Standard Deviation Function Examples
Suppose we have a table named “Employee” with the data as shown below.
Employee_Id | Employee_Name | Salary | Department | Commission |
101 | Emp A | 10000 | Sales | 10 |
102 | Emp B | 20000 | IT | 20 |
103 | Emp C | 28000 | IT | 20 |
104 | Emp D | 30000 | Support | |
105 | Emp E | 32000 | Sales | 10 |
Oracle STDDEV Function application is shown below.
SQL Standard Deviation – SQL STDDEV Simple Usage Example
SQL Standard Deviation query below will return the standard deviation of salaries of all employees.
SELECT STDDEV(salary) "SQL STDDEV" FROM employee;
Above Oracle Standard Deviation query returns ‘9055.38513813742’ as standard deviation of all salaries in ‘employee’ table.
Note: We have aliased STDDEV(salary) as SQL STDDEV.
Oracle Standard Deviation – Oracle STDDEV Using Formula Example
SQL Standard Deviation query below calculates the Standard Deviation of Salary*Commission for ’employee’ table.
SELECT STDDEV(salary*(commission/100)) "Oracle STDDEV" FROM employee;
Above Oracle Standard Deviation query returns ‘1913.98362932741’ as standard deviation of all salary*(commission/100) of ‘employee’ table.
Note: We have aliased STDDEV(salary*(commission/100)) as Oracle STDDEV.