oracle分組查詢(某年12月的數據和每年每月的數據)


//查詢某年1-12月的數據

select to_char(createdate,'yyyy-mm') 月份,count(*) 數量 from cms_news where ispub='1' 

and createdate between to_date('2014-01','yyyy-mm') and to_date('2014-12','yyyy-mm') group by to_char(createdate,'yyyy-mm') order by to_char(createdate,'yyyy-mm');

 

//查詢每年每月的數據

select to_char(createdate,'yyyy-mm') 月份,count(*) 數量 from cms_news group by to_char(createdate,'yyyy-mm') order by to_char(createdate,'yyyy-mm');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM