Friday, September 11, 2009

sql for monthly,yearly report

select year(added_on),month(added_on),count(*) from table_name
group by 1,2
order by 2


This will produce a resultset for monthly yearly reports.

Ex :-

Year Month Records
------ ------ --------
2009 5 14416
2009 6 788
2009 7 15413
2009 8 16091

No comments:

Post a Comment