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
【功能】统计数据表选中行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
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。