Skip to content

Instantly share code, notes, and snippets.

@bitner
Last active July 15, 2020 18:35
Show Gist options
  • Save bitner/5a4e5b811871c969d2c37c4f3dca5b52 to your computer and use it in GitHub Desktop.
Save bitner/5a4e5b811871c969d2c37c4f3dca5b52 to your computer and use it in GitHub Desktop.
OpenAQ Data Compare Queries
-- PostgreSQL
select
row_number() over (order by date_utc asc, location, parameter),
location,
value,
parameter,
country,
city,
date_utc
from measurements
where
date_utc between '2020-07-01T00:00:00Z' and '2020-07-07T00:00:00Z'
and location='Abbotsford'
order by date_utc asc, location, parameter;
-- Athena
SELECT location,
value,
parameter,
country,
city,
from_iso8601_timestamp(date.utc) as date_utc
FROM openaq
WHERE
location = 'Abbotsford' AND
from_iso8601_timestamp(date.utc)
BETWEEN from_iso8601_timestamp('2020-07-01T00:00:00Z')
AND from_iso8601_timestamp('2020-07-07T00:00:00Z')
ORDER BY from_iso8601_timestamp(date.utc) asc, lower(location), parameter
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment