oracle 按天天,每周,每个月,每季度,每一年查询统计数据

//按天统计sql

select count(dataid) as 天天操做数量, sum()table

from tablenamedate

group by trunc(createtime, 'DD'))select

//按天然周统计 
select to_char(date,'iw'),sum() 
from  tablename
group by to_char(date,'iw') im

//按天然月统计 
select to_char(date,'mm'),sum() 
from   tablename
group by to_char(date,'mm') call

//按季统计 
select to_char(date,'q'),sum() 
from  tablename
group by to_char(date,'q') 统计

//按年统计 
select to_char(date,'yyyy'),sum() 
from  tablename
group by to_char(date,'yyyy')tab

sql = " select (to_char(createdate, 'yyyy')||'年'||to_char(createdate, 'q')||'季度')time, count(1) call_count"+
                            " from SOA_SERVICE_INFO"+
                            " where to_char(createdate, 'yyyy')=2018"+
                            " group by to_char(createdate, 'q'),to_char(createdate, 'yyyy')"+
                            " order by to_char(createdate, 'q')";co