SQL 按周,月,季度,年查詢統計數據

//按自然周統計 
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')


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章