Variance and standard deviation can only be used for numeric columns, and the NULL
value will be ignored.
One, variance and standard deviation
The calculation formula of population variance:
In actual tests, the mean of the population is difficult to obtain. It is necessary to use sample statistics instead of population parameters, and the data needs to be corrected. The calculation formula of sample variance:
the syntax of variance:
VAR ( [ ALL | DISTINCT ] expression )
VARP ( [ ALL | DISTINCT ] expression )
Syntax for standard deviation:
STDEV ( [ ALL | DISTINCT ] expression )
STDEVP ( [ ALL | DISTINCT ] expression )
The difference between functions with P
and without P
: VAR
and STDEV
refers to the variance and standard deviation of the population, VARP
and the sum STDEVP
refers to the variance and standard deviation of the sample.
MSSQL function- STDEV
standard deviation and STDEVP
standard deviation
StDev
The function is to calculate the standard deviation of all the values of the specified field in the query result. It is a program used to measure the deviation of the data from the arithmetic mean. The smaller the standard deviation, the less these values deviate from the mean, and vice versa. This function does not calculate text values and logical values (such as TRUE
sums FALSE
). It reflects the degree of dispersion of the data relative to the average. For example, find the N
standard deviation of each value and the square sum of the difference between each data and the average value divided by ( N-1
) and then open the root sign.
StDevP
The function is to calculate the standard deviation of all the values of the specified field in the query result, which is used to measure the degree of dispersion of the data set (also called the deviation from the mean). The smaller the standard deviation, the smaller the fluctuation of this group of data. Conversely, the larger the standard deviation, the greater the fluctuation of this set of data. The algorithm is seeking N
the number of standard deviations from the mean for each data divided by the square of the difference between N
the square root, a bit like a standard deviation from the calculated data with the standard deviation about the same.
StDev
The standard deviation calculated by the function is a program used to measure the deviation of the data from the arithmetic mean. The StDevP
calculated standard deviation is used to measure the degree of dispersion of the data set. Sometimes it is understood as the same, but there are subtle differences. The data is also There are some differences.
STDEVP
Function and STDEV
function as in does not OVER
and ORDER BY
when used in conjunction with deterministic function clauses whose return value. And if OVER
and ORDER BY
when used with the clause, it is uncertain. This is the characteristic of all aggregate functions, and we must pay attention here.
sqlserver
Find the standard deviation, oracle
find the standard deviation
oracle find the standard deviation:
select STDdEV(column1) from (
select 50 column1 from dual
union
select 90 from dual
union
select 70 from dual) tt
Find the standard deviation in sqlserver:
select STDEV(column1) from (
select 50 column1
union
select 90
union
select 70 ) tt