Here is my below query which gives the count and group by each hour
SELECT ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time)) as time , to_integer(to_varchar(start_time, 'DD')) as day , count(*) as count FROM SYSTEM.TABLE where start_time >= '2016-01-01 00:00:00' and start_time <= '2016-01-01 23:59:59' and place_id=1 group by ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time)),to_integer(to_varchar(start_time, 'DD'))
order by ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time))
But at the time period 11:00 pm to 12:00 pm I have no count so instead of not returning the row I want it to return the row with 0.
So when I went through some search I found that COALESCE can help so I tried with
SELECT COALESCE (( SELECT ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time)) as time , to_integer(to_varchar(start_time, 'DD')) as day , count(*) as count FROM SYSTEM.TABLE where start_time >= '2016-01-01 00:00:00' and start_time <= '2016-01-01 23:59:59' and place_id=1 group by ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time)),to_integer(to_varchar(start_time, 'DD'))
order by ADD_SECONDS(start_time,- MINUTE(start_time) * 60 - SECOND(start_time))
), 0);
But it did not also work. Any help is appreciated.