i have a table that have the following columns and sample data.
(this data is output of a query so i have to use that query in FROM () statement)
Type| Time | Count
--------------------------------
1 |2013-05-09 12:00:00 | 71
2 |2013-05-09 12:00:00 | 48
3 |2013-05-09 12:00:00 | 10
3 |2013-05-09 13:00:00 | 4
2 |2013-05-16 13:00:00 | 30
1 |2013-05-16 13:00:00 | 31
1 |2013-05-16 14:00:00 | 4
3 |2013-05-16 14:00:00 | 5
I need to group data based on time so my output should look like this
AlarmType1 | AlarmType2 |AlarmType3| AlarmTime
--------------------------------
71 | 48 | 10 | 2013-05-09 12:00:00
31 | 30 | 4 | 2013-05-09 13:00:00
4 | 0 | 5 | 2013-05-09 14:00:00
i have tried this query
SELECT
SUM(IF (AlarmType = '1',1,0)) as AlarmType1,
SUM(IF (AlarmType = '2',1,0)) as AlarmType2,
SUM(IF (AlarmType = '3',1,0)) as AlarmType3,
AlarmHour
FROM 'Table1'
GROUP BY Time
but this did not work, as i am missing Count in my Query, have to adjust Count im my Query