MySQL Query with count and group by
I’ve got table a table with different records for publishers, each record have a date in a column of type timestamp.
id | id_publisher | date1 1 11/2012 03:09:40 p.m.2 1 12/2012 03:09:40 p.m.3 2 01/2013 03:09:40 p.m.4 3 01/2013 03:09:40 p.m.5 4 11/2012 03:09:40 p.m.6 4 02/2013 03:09:40 p.m.7 4 02/2012 03:09:40 p.m.
I need a count for number of records published by each publisher for each month. For example
Month | id_publisher | num11/2012 | 1 | 111/2012 | 2 | 011/2012 | 3 | 011/2012 | 4 | 1.....02/2013 | 4 | 2
I tried withselect count(id) from raw_occurrence_record group by month(date), id_publisher;
but, it did not work.