Created
July 2, 2014 16:45
-
-
Save wboykinm/6f6d5c79db21e87d0803 to your computer and use it in GitHub Desktop.
Match geoid from ACS table to Tiger block groups
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
DROP TABLE IF EXISTS income_join; | |
CREATE TABLE | |
income_join | |
AS ( | |
WITH table_b19013 AS ( | |
SELECT | |
substring(geoid FROM 8 FOR 12) geoid, | |
b19013001 | |
FROM | |
acs2012_5yr.b19013 | |
WHERE | |
length(substring(geoid FROM 8 FOR 12)) = 12 | |
) | |
SELECT | |
bg.geoid, | |
bg.the_geom, | |
bg.namelsad, | |
acs.b19013001 | |
FROM | |
tiger2012.bg bg | |
LEFT OUTER JOIN | |
table_b19013 acs | |
ON | |
(bg.geoid = acs.geoid) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment