分享

oracle 实现按天,周,月,季度,年查询统计数据

 hh3755 2012-03-13
//按天统计
select count(dataid) as 每天操作数量, sum()
from
where
group by trunc(createtime, 'DD'))
//按自然周统计 
select to_char(date,'iw'),sum() 
from 
where 
group by to_char(date,'iw') 
//按自然月统计 
select to_char(date,'mm'),sum() 
from 
where 
group by to_char(date,'mm') 
//按季统计 
select to_char(date,'q'),sum() 
from 
where 
group by to_char(date,'q') 
//按年统计 
select to_char(date,'yyyy'),sum() 
from 
where 
group by to_char(date,'yyyy')

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多