I am trying to get the total number of "ID User" that was logged in every hour! but what is happening sometime there is no users were loggedin in particular hour and I wanted to show that hour there is Zero users was loggedin. I think to solve this I should of using a join table with all the hours that are between those two date that i am filtering by. any suggestion for this problem?
SELECT FORMAT(chDate,'yyyy-MM-dd H:00:00') as cDate , count(ID) as nValue FROM myDB.myTable Where chDate > '2014-11-03 00:00:00' and chDate < '2014-11-03 4:00:00' Group by FORMAT(chDate,'yyyy-MM-dd H:00:00') The resault I got
cDate nValue 2014-11-03 0:00:00 5 2014-11-03 3:00:00 8 The resault I want
cDate nValue 2014-11-03 0:00:00 5 2014-11-03 1:00:00 0 2014-11-03 2:00:00 0 2014-11-03 3:00:00 8