Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to report on data in e-email messaging system and wanted to have SQL tally counts by month/year.

select year(crdate ) as y, month(crdate )  as m, count(*) as tally from message 
where year(crdate ) = 2012
and subject <> 'Welcome' -- exclude default messages
group by year(crdate ), month(crdate )

This is what I have but its limiting in that I need to manually change years. Can this be upgraded to output for all dates in the table in this month/year format?

share|improve this question
2  
Removing the year(crdate ) = 2012 condition? – ypercube Feb 1 at 15:51
Please edit the question if @ypercube's comment above doesn't solve things for you: assuming it does I'm closing as 'too basic' for dba.se :) – Jack Douglas Feb 1 at 16:08

closed as off topic by ypercube, Jack Douglas Feb 1 at 16:08

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.