All About SQL Functions - STDEV (
Page 3 of 6 )
When you are dealing with a huge amount of data, STDEV can return the Standard Deviation of a column. You have to have a minimum of two values or the value returned will be null.
Here is how it looks in code:
Select STDEV(Salary) As SDSalary
From Employees
The above function takes a sampling of your data instead of the whole list, and returns the standard deviation.
STDEVP
If you want to work with all the data in a column to find the standard deviation, you can use STDEVP instead.
Select STDEVP(Salary) As DevSalary
From Employees
VAR
The VAR Function allows you to find the variance of a set of data from a column. Like STDEV, VAR only works with a sampling and not the whole column. And again, you must have at least two values in the column or a null will be returned.
Select VAR(Salary) As VARSalary
From Employees
VARP
To get a variance using all of the data in a column, use this handy little guy.
Select VARP(Salary) As VARPSalary
From Employees