I have a collcation similar to this one:
http://sqlfiddle.com/#!2/fecbc/3
My problem is I would like when I use group by HOUR(date)
hours like 2
, 3
, and 4
appears but with 0
.
Actually they disappear of the result.
How can I perform this?
What is the simply way to do this?
Is there a way to avoid 24 ifs statements?
Can we avoid to create another table?
If you don't want to create a table for this, you can use a subquery that enumerates the hours from 0 to 23:
You will need a table that contains 24 hours, then
JOIN
to it. If you're not able to create a table, then you can create it inside your query. See this demo.