Oracle按不同时间分组统计的sql以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
Oracle按不同时间分组统计的sql
如下表table :
日期(exportDate) 数量(amount)
月
月
月
月
月
月
月
月
月
注意 为了显示更直观 如下查询已皆按相应分组排序
按年份分组
select to_char(exportDate yyyy ) sum(amount) from table group by to_char(exportDate yyyy )
年份 数量
按月份分组
select to_char(exportDate yyyy mm ) sum(amount) from table group by to_char(exportDate yyyy mm )
order by to_char(exportDate yyyy mm )
月份 数量
按季度分组
select to_char(exportDate yyyy Q ) sum(amount) from table group by to_char(exportDate yyyy Q )
order by to_char(exportDate yyyy Q )
季度 数量
按周分组
select to_char(exportDate yyyy IW ) sum(amount) from table group by to_char(exportDate yyyy IW )
order by to_char(exportDate yyyy IW )
周 数量
lishixinzhi/Article/program/Oracle/201311/17995
分页:123