Using Oracle to calculate variance and standard deviation

Source: Internet
Author: User

/* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.