Reputation: 63
I am trying to find out if it is possible to query between 2 hours and parse per hour EG
SELECT COUNT(*) FROM `production` WHERE `area` = '1' AND `datetime` BETWEEN '2016-10-21 08:00:00' AND "2016-10-21 10:00:00"
Result = 57
If it is possible i would like the output like this:
08:00 - 09:00 - 30
09:00 - 10:00 - 27
I am using PDO.
Thanks
Upvotes: 0
Views: 112
Reputation: 63
I Found This Can Be Done At The SQL Level
SELECT HOUR(datetime), COUNT(*) FROM production
WHERE `area` = '1' AND `datetime` BETWEEN '2016-10-21 08:00:00' AND "2016-10-21 10:00:00"
GROUP BY HOUR(datetime)
This Returns
HOUR(datetime) - COUNT(*)
8 - 30
9 - 27
10 - 21
Upvotes: 1