Last active
December 10, 2015 03:32
-
-
Save parkercoleman/04d3baca58630afcc745 to your computer and use it in GitHub Desktop.
Maptime Seattle Postgis - Problem 4
This file contains 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
WITH county_hurricanes AS ( | |
SELECT DISTINCT c.name AS county_name, s.name AS state_name, h.serial_num | |
FROM geo.counties_cb c | |
INNER JOIN geo.states_ne s ON c.statefp = right(s.fips, 2) --The FIPS codes in the state table have "US" infront of them, the right() function trims that | |
INNER JOIN weather.hurricane_lines_noaa h ON ST_Intersects(c.geom, h.geom) | |
WHERE s.admin = 'United States of America' | |
) | |
SELECT county_name, state_name, COUNT(*) | |
FROM county_hurricanes | |
GROUP BY county_name, state_name | |
ORDER BY COUNT(*) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment