Created
March 22, 2010 17:56
-
-
Save adamcharnock/340321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TEMPORARY TABLE IF EXISTS siteswith30days; | |
CREATE TEMPORARY TABLE siteswith30days SELECT r2.siteid, COUNT(*) as totalrows FROM rawdata AS r2 GROUP BY siteid HAVING totalrows > 6*24*30; | |
SELECT | |
r.*, | |
(r.winddirection % 1024) * (360/1024) AS winddirectiondegrees, | |
0.8669 * (r.windpulsecount/600) + 0.32 AS windspeed, | |
s.postcode, | |
s.anemometerheight | |
FROM | |
rawdata AS r | |
INNER JOIN sites AS s USING (siteid) | |
INNER JOIN siteswith30days USING (siteid) | |
WHERE | |
s.country="GB" AND | |
s.anemometerheight = 12 | |
ORDER BY s.siteid, r.sampledate | |
INTO OUTFILE "/tmp/suzie-data.csv"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment