Mysql: Group by Hour, 0 if no data
I have the following query: SELECT count(*) as 'totalCalls', HOUR(`end`) as 'Hour' FROM callsDataTable WHERE company IN ( SELECT number FROM products WHERE products.id IN (@_PRODUCTS)) AND YEAR(`end`) = @_YEAR AND MONTH(`end`) = @_MONTH group by HOUR(`end`) Above query returns only the hours in which there where calls made: totalCalls Hour 2 0 1 2 4 7 98 8 325 9 629 10 824 13 665 15 678 16 665 17 606 18 89 22 5 23 The desired output should be all the hours, and where there are no calls it should be 0 calls for that hour, like below: totalCalls Hour 0 0 0 1 1 2 0 3 0 4 0 5 0 6 4 7 98 8 325 9