UPDATE
I found this query :
SELECT CONCAT(DATE(gid), ' / ', HOUR(gdate), ':00:00 to ', CONCAT(HOUR(gdate), ':59:59')) as slice,
COUNT(*)
FROM t_table
GROUP BY
DATE(gdate),
HOUR(gdate);
It doesnt output a ZERO when there is no data for a period of 8 hours or for a day. Is there a way ?
I have a table which has 3 fields :
- gid (int)
- gdate (datetime)
- ginfo (text)
I want to find the correct query that would ouput the number of items (field ginfo) for every 8 hours every day between two dates. I am not sure if it's clear so I can try to schematize it :
The first date is : 2013/10/01.
The second date is : 2013/10/03.
For the first day the PHP output would be for example:
2013/10/01 00:00-07h59 : 8
2013/10/01 08:00-15h59 : 5
2013/10/01 16:00-23h59 : 7
For the second day the PHP output would be for example :
2013/10/01 00:00-07h59 : 2
2013/10/01 08:00-15h59 : 3
2013/10/01 16:00-23h59 : 1
etc.
In the table, there are 20 items for 2013/10/01. In the table, there are 6 items for 2013/10/02.
I can't find the correct query.
Can anyone help me ?
Excuse my poor english.