I am trying to group the last 24 Hours of analytics by hour
this is my table.
I can run this query and it will group with a total.
SELECT SUM( watched_time ) AS total
FROM wp_video_analytics_time
WHERE created > DATE_SUB(NOW(), INTERVAL 24 HOUR)
GROUP BY HOUR(created)
It outputs.
What I am trying to achieve is to output the date alongside the grouped column.
Something like this.
I am trying to do this so I can add this data to a Google chart and display the time watched in the last 24 hours.
Ideally I would like the whole 24 hours with zero values if there is no data. But any help would be appreciated at this stage.
Ok so I have the hours working.
SELECT SUM( watched_time ) AS total, HOUR(created) AS hours
FROM wp_video_analytics_time
WHERE created > DATE_SUB(NOW(), INTERVAL 24 HOUR)
GROUP BY HOUR(created)
Can anyone explain how to add the zero values for hours that dont have any data this does not seem simple.