oracle函数 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

猜你喜欢

转载自www.cnblogs.com/fanweisheng/p/11119334.html