oracle 聚组函数
来源:互联网 发布:淘宝美工要学多久 编辑:程序博客网 时间:2024/04/30 03:31
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
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.77VARIANCE([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.9712count(*|[distinct|all]x)【功能】统计数据表选中行x列的合计值。【参数】*表示对满足条件的所有行统计,不管其是否重复或有空值(NULL)all表示对所有的值统计,默认为alldistinct只对不同的值统计,如果有参数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 5MIN([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
0 0
- oracle 聚组函数
- ORACLE常用函数之聚组函数
- oracle---常用函数2---聚组函数
- oracle组函数(聚组函数)总结
- Oracle DB 组函数
- oracle组函数
- Oracle DB 组函数
- ORACLE单行函数与组函数详解
- Oracle多行函数(组函数)
- Oracle多行函数/组函数
- oracle 组函数的使用
- Oracle 表操作-组函数
- Oracle学习(四):组函数
- 10、Oracle的组函数
- Oracle函数
- oracle 函数
- Oracle函数
- Oracle函数
- windows网络编程学习笔记一
- poj2253-我的第一篇floyd
- ZOJ-2165
- PAT1055. The World's Richest
- adb命令安装和卸载apk文件
- oracle 聚组函数
- JSONObject与JSONArray的使用
- 内存泄露和内存溢出区别
- 闲扯LUA之一
- 最长不重复子串
- 继承
- tiny6410: linux内核移植以及文件系统
- 动态规划小结
- 修复Linux引导(二):unknown filesystem,引导菜单无法启动系统,使用LiveCD修复