/* Formatted on 5/24/2012 4:15:58 PM (QP5 v5.149.1003.31008) */
SELECT Deptno,
ename,--st_name | | "| | Last_Name Employee_Name,
HireDate,
Sal
STDDEV (SAL) over (PARTITION by Deptno ORDER by HireDate) as "STDDEV", standard deviation
Stddev_samp (SAL) over (PARTITION by Deptno ORDER by HireDate)
As "Stddev_samp",--sample standard deviation
Var_pop (SAL) over (PARTITION by deptno ORDER by HireDate) Description: Var_pop is a function, Sal is a required data column, with ' Deptno ' as the basis for grouping, i.e. The operation of variance is satisfied under this condition, and finally is sorted according to ' HireDate '.
as "Var_pop",--variance
Var_samp (SAL) over (PARTITION by Deptno ORDER by HireDate)
As "Var_samp"--sample variance
From Scott.emp
WHERE Deptno in (20);
/* Formatted on 5/24/2012 4:15:58 PM (QP5 v5.149.1003.31008) */
SELECT Deptno,
STDDEV (SAL) as "STDDEV", standard deviation
Stddev_samp (SAL)
As "Stddev_samp",--sample standard deviation
Var_pop (SAL)
as "Var_pop",--variance
Var_samp (SAL)
As "Var_samp"--sample variance
From Scott.emp
GROUP BY Deptno
Using Oracle to calculate variance and standard deviation