I have a mysql table where each entry contains among other, a location string and a datetime field.
I would like to build a mysql query that generates a report with the count(items) grouped by hour of day (on the rows) and the locations (on the columns).
So far I'm manually generating reports grouped by location and I have a WHERE clause where I iterate over each hour of day (24 in number). This is too cumbersome and I would like to do it automatically.
EDIT
This is the query i'm now trying to use based on the answer from fxzuz
SELECT locations.locationName, DATE_FORMAT( '%Y-%m-%d %H', entries.CreatedOn ) , COUNT( pk_entry )
FROM entries
LEFT JOIN locations ON locations.computerName = entries.location
GROUP BY DATE_FORMAT( '%Y-%m-%d %H', entries.CreatedOn )