Skip to content

Instantly share code, notes, and snippets.

@yurukov
Created February 23, 2016 20:10
Show Gist options
  • Save yurukov/1158717736677b3568a2 to your computer and use it in GitHub Desktop.
Save yurukov/1158717736677b3568a2 to your computer and use it in GitHub Desktop.
Get the 24 h average level for PM10 in Sofia air quality data
SELECT a.timest,a.level, a.isinvalid, (select round(avg(a1.level)) from air_sofia a1 where a1.station=a.station and a1.param=0 and a1.isinvalid=0 and a1.timest>=a.timest - interval 12 hour and a1.timest<a.timest + interval 12 hour) level24,(select count(a2.level) from air_sofia a2 where a2.station=a.station and a2.param=0 and a2.isinvalid=0 and a2.timest>=a.timest - interval 12 hour and a2.timest<a.timest + interval 12 hour) validcount FROM air_sofia a where param=0 and station=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment