SQL内置函数的使用方法及结果(12)

开发者在线 Builder.com.cn 更新时间:2008-04-23作者:gissky 来源:51cto.com

本文关键词: 函数 SQL 数据库 Oracle

64.VARIANCE(DISTINCT|ALL) 求协方差

SQL> select variance(sal) from scott.emp;

VARIANCE(SAL)

-------------

1398313.9

65.GROUP BY 主要用来对一组数进行统计

SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno;

DEPTNO COUNT(*) SUM(SAL)

--------- --------- ---------

10 3 8750

20 5 10875

30 6 9400

66.HAVING 对分组统计再加限制条件

SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno having nt(*)>=5;

DEPTNO COUNT(*) SUM(SAL)

--------- --------- ---------

20 5 10875

30 6 9400

SQL> select deptno,count(*),sum(sal) from scott.emp having count(*)>=5 group by tno ;

DEPTNO COUNT(*) SUM(SAL)

--------- --------- ---------

20 5 10875

30 6 9400

67.ORDER BY 用于对查询到的结果进行排序输出

SQL> select deptno,ename,sal from scott.emp order by deptno,sal desc;

DEPTNO ENAME SAL

--------- ---------- ---------

10 KING 5000

10 CLARK 2450

10 MILLER 1300

20 SCOTT 3000

20 FORD 3000

20 JONES 2975

20 ADAMS 1100

20 SMITH 800

30 BLAKE 2850

30 ALLEN 1600

30 TURNER 1500

30 WARD 1250

30 MARTIN 1250

30 JAMES 950

用户评论

  • 用户名
  • 评论内容