码迷,mamicode.com
首页 > 数据库 > 详细

使用oracle来计算方差及标准差

时间:2016-06-17 21:11:54      阅读:2403      评论:0      收藏:0      [点我收藏+]

标签:

/* 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", --标准差
       STDDEV_SAMP (sal) OVER (PARTITION BY deptno ORDER BY hiredate)
          AS "STDDEV_SAMP",                                            --样本标准差
       VAR_POP (sal) OVER (PARTITION BY deptno ORDER BY hiredate)    说明:VAR_POP 为函数, sal为要求的数据列,  以‘deptno’为分组的根据,即满足这个条件下才进行方差的操作,最后根据‘hiredate’进行排序。
          AS "VAR_POP",                                                   --方差
       VAR_SAMP (sal) OVER (PARTITION BY deptno ORDER BY hiredate)
          AS "VAR_SAMP"                                                 --样本方差
  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", --标准差
       STDDEV_SAMP (sal)
          AS "STDDEV_SAMP",                                            --样本标准差
       VAR_POP (sal)
          AS "VAR_POP",                                                   --方差
       VAR_SAMP (sal)
          AS "VAR_SAMP"                                                 --样本方差
  FROM scott.emp
group  by deptno

使用oracle来计算方差及标准差

标签:

原文地址:http://www.cnblogs.com/AdaLoong/p/5595054.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!