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