Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Created November 29, 2012 13:00
Show Gist options
  • Save kylejohnson/4168901 to your computer and use it in GitHub Desktop.
Save kylejohnson/4168901 to your computer and use it in GitHub Desktop.
select time_format(from_unixtime(statDate), '%H') as Date , avg( case when SensorID = 1 then StatValue ELSE 0 END) as 'Room 1' , avg( case when SensorID = 2 then StatValue ELSE 0 END) as 'Room 2' , avg( case when SensorID = 3 then StatValue ELSE 0 END) as 'Room 3' from stats where date(from_unixtime(statDate)) = curdate() group by time_format(from_unixtime(statDate), '%H') order by StatDate ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment