sql中select查询后的数字型字段汇总问题

来源:百度知道 编辑:UC知道 时间:2024/06/15 16:48:59
ORCLE数据库用select查询出来的记录,要把其中的数值型字段汇总,有什么简单的操作,而不用遍历所有记录
已经查询出来的记录要再把其中的数值型字段汇总。
查询语句为:select hm,sum(charge) charge from owe group by hm
再查询出来的结果的基础上要把charge这个字段再汇总。

select hm,sum(charge) charge from owe group by rollup(hm)

你可以baidu一下 rollup,grouping等关键字的用法,详细了解一下

select sum(数值型字段) as total from 表

select sum(charge) charge from( select hm,sum(charge) charge from owe group by hm ) T