Created
June 2, 2015 22:52
-
-
Save mapsam/7bf37e7e7b9bae5dbed5 to your computer and use it in GitHub Desktop.
abq_sql_tableflip
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
SELECT | |
zip_codes, | |
SUM (case WHEN type = 'jobs' THEN cnt ELSE 0 END) AS jobs, | |
SUM (case WHEN type = 'education' THEN cnt ELSE 0 END) AS education, | |
SUM (case WHEN type = 'housing' THEN cnt ELSE 0 END) AS housing, | |
SUM (case WHEN type = 'childcare' THEN cnt ELSE 0 END) AS childcare, | |
SUM (case WHEN type = 'transportation' THEN cnt ELSE 0 END) AS transportation, | |
SUM (case WHEN type = 'health' THEN cnt ELSE 0 END) AS health, | |
SUM (case WHEN type = 'grants' THEN cnt ELSE 0 END) AS grants, | |
SUM (case WHEN type = 'food' THEN cnt ELSE 0 END) AS food | |
FROM | |
( | |
SELECT x.zip_codes, x.type, COUNT(*) AS cnt | |
FROM abq_nfp_types_1 x JOIN zipcodes_abq y ON x.zip_codes::VARCHAR = y.geoid10 | |
WHERE zip_codes::VARCHAR = geoid10 | |
group by 1, 2 | |
) z | |
GROUP BY 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment