您当前的位置: 首页 > 数据库教程 > Oracle教程 > oracle聚组函数

oracle聚组函数

作者:不详 来源:网络 发布时间: 2014-08-25 17:08 点击:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 AVG([distinct|all]x) 【功能】统计数据表选中行x列的平均值。 【参数】all表示对所有的值求平均值,distinct只对不同的值求平均值,默认为all 如果有参数distinct或all,需有空格与x(列)隔开。 【参数】x,只能

oracle聚组函数

  

  

  

  

  

  

  

  


  1

  2

  3

  4

  5

  6

  7

  8

  9

  10

  11

  12

  13

  14

  15

  16

  17

  18

  19

  20

  21

  


  AVG([distinct|all]x)

  【功能】统计数据表选中行x列的平均值。

  【参数】all表示对所有的值求平均值,distinct只对不同的值求平均值,默认为all

  如果有参数distinct或all,需有空格与x(列)隔开。

  【参数】x,只能为数值型字段

  【返回】数字值

  【示例】

  环境:

  create table table3(xm varchar(8),sal number(7,2));

  insert into table3 values('gao',1111.11);

  insert into table3 values('gao',1111.11);

  insert into table3 values('zhu',5555.55);

  commit;

  执行统计:

  select avg(distinct sal),avg(all sal),avg(sal) from table3;

  结果: 3333.33 2592.59 2592.59

  


  ?

  

  

  

  

  

  

  

  


  1

  


  SUM([distinct|all]x) 【功能】统计数据表选中行x列的合计值。 【参数】all表示对所有的值求合计值,distinct只对不同的值求合计值,默认为all 如果有参数distinct或all,需有空格与x(列)隔开。 【参数】x,只能为数值型字段 【返回】数字值 【示例】 环境: create table table3(xm varchar(8),sal number(7,2)); insert into table3 values('gao',1111.11); insert into table3 values('gao',1111.11); insert into table3 values('zhu',5555.55); commit; 执行统计: select SUM(distinct sal),SUM(all sal),SUM(sal) from table3; 结果: 6666.66 7777.77 7777.77

  


  ?

  

  

  

  

  

  

  

  


  1

  


  VARIANCE([distinct|all]x) 【功能】统计数据表选中行x列的方差。 【参数】all表示对所有的值求方差,distinct只对不同的值求方差,默认为all 如果有参数distinct或all,需有空格与x(列)隔开。 【参数】x,只能为数值型字段 【返回】数字值 【示例】 环境: create table table3(xm varchar(8),sal number(7,2)); insert into table3 values('gao',1111.11); insert into table3 values('gao',1111.11); insert into table3 values('zhu',5555.55); commit; 执行统计: select VARIANCE(distinct sal),VARIANCE(all sal),VARIANCE(sal) from table3; 结果: 9876523.4568 6584348.9712 6584348.9712

  


  ?

  

  

  

  

  

  

  

  


  1

  


  count(*|[distinct|all]x) 【功能】统计数据表选中行x列的合计值。 【参数】 *表示对满足条件的所有行统计,不管其是否重复或有空值(NULL) all表示对所有的值统计,默认为all distinct只对不同的值统计, 如果有参数distinct或all,需有空格与x(列)隔开,均忽略空值(NULL)。 【参数】x,可为数字、字符、日期型及其它类型的字段 【返回】数字值 count(*)=sum(1) 【示例】 环境: create table table3(xm varchar(8),sal number(7,2)); insert into table3 values('gao',1111.11); insert into table3 values('gao',1111.11); insert into table3 values('zhu',5555.55); insert into table3 values('',1111.11); insert into table3 values('zhu',0); commit; 执行统计: select count(*),count(xm),count(all xm),count(distinct sal),count(all sal),count(sal),sum(1) from table3; 结果: 5 4 4 3 5 5 5

  


  ?

  

  

  

  

  

  

  

  


  1

  


  MIN([distinct|all]x) 【功能】统计数据表选中行x列的最大值。 【参数】all表示对所有的值求最大值,distinct只对不同的值求最大值,默认为all 如果有参数distinct或all,需有空格与x(列)隔开。 【参数】x,可为数字、字符或日期型字段 【返回】对应x字段类型 注:字符型字段,将忽略空值(NULL) 【示例】 环境: create table table3(xm varchar(8),sal number(7,2)); insert into table3 values('gao',1111.11); insert into table3 values('gao',1111.11); insert into table3 values('zhu',5555.55); insert into table3 values('',1111.11); insert into table3 values('zhu',0); commit; 执行统计: select MIN(distinct sal),MIN(xm),MIN(distinct xm),MIN(all xm) from table3; 结果:0 gao gao gao

  
分享到:
本文"oracle聚组函数"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4