mysql - Count totals by year and month -
i have table looks this:
id,created,action 1,'2011-01-01 04:28:21','signup' 2,'2011-01-05 04:28:21','signup' 3,'2011-02-02 04:28:21','signup'
how select , group these output is:
year,month,total 2011,1,2 2011,2,1
try this:
select date_format(created, '%y') 'year', date_format(created, '%m') 'month', count(id) 'total' table_name group date_format(created, '%y%m')
Comments
Post a Comment