I am new to SQL and facing a trouble in grouping.I have a query which gives a table like
time state1
____ ______
2015-04-01 00:00:00 10
2015-04-01 00:00:00 05
2015-04-01 00:00:00 08
2015-04-01 01:00:00 12
2015-04-01 01:00:00 15
2015-04-01 01:00:00 30
2015-04-01 02:00:00 11
2015-04-01 02:00:00 10
2015-04-01 02:00:00 27
The query i am using is
SELECT time,state1
FROM public.block_table
where time >= '2015-04-01 00:00:00'
and time <= '2015-04-01 23:59:59'
group by time, state1
order by time;
Instead of this I want to have this grouped
time state1
____ ______
2015-04-01 00:00:00 23
2015-04-01 00:00:00 57
2015-04-01 00:00:00 48
I know I am missing a group function.