打印本文 打印本文 关闭窗口 关闭窗口
Oracle SQL 內置函數大全
作者:武汉SEO闵涛  文章来源:敏韬网  点击数6804  更新时间:2009/4/22 22:02:47  文章录入:mintao  责任编辑:mintao
>SQL> select min(all sal) from gao.table3;
666
667MIN(ALLSAL)
668-----------
669    1111.11
670
671
67263.STDDEV(distinct|all)
673求标准差,ALL表示对所有的值求标准差,DISTINCT表示只对不同的值求标准差
674SQL> select stddev(sal) from scott.emp;
675
676STDDEV(SAL)
677-----------
678  1182.5032
679
680SQL> select stddev(distinct sal) from scott.emp;
681
682STDDEV(DISTINCTSAL)
683-------------------
684           1229.951
685
686 
687
68864.VARIANCE(DISTINCT|ALL)
689求协方差 
690
691SQL> select variance(sal) from scott.emp;
692
693VARIANCE(SAL)
694-------------
695    1398313.9
696
697
69865.GROUP BY
699主要用来对一组数进行统计
700SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno;
701
702   DEPTNO  COUNT(*)  SUM(SAL)
703--------- --------- ---------
704       10         3      8750
705       20         5     10875
706       30         6      9400
707
708 
709
71066.HAVING
711对分组统计再加限制条件
712SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno having count(*)>=5;
713
714   DEPTNO  COUNT(*)  SUM(SAL)
715--------- --------- ---------
716       20         5     10875
717       30         6      9400
718SQL> select deptno,count(*),sum(sal) from scott.emp having count(*)>=5 group by deptno ;
719
720   DEPTNO  COUNT(*)  SUM(SAL)
721--------- --------- ---------
722       20         5     10875
723       30         6      9400
724
725
72667.ORDER BY
727用于对查询到的结果进行排序输出
728SQL> select deptno,ename,sal from scott.emp order by deptno,sal desc;
729
730   DEPTNO ENAME            SAL
731--------- ---------- ---------
732       10 KING            5000
733       10 CLARK           2450
734       10 MILLER          1300
735       20 SCOTT           3000
736       20 FORD            3000
737       20 JONES           2975
738       20 ADAMS           1100
739

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  下一页

打印本文 打印本文 关闭窗口 关闭窗口