Last active
December 27, 2015 02:19
-
-
Save JoeGermuska/7251437 to your computer and use it in GitHub Desktop.
Finding fragments of census tracts that are not in a place (in this case, Chicago) when other parts of the tract are in that place. Working against Census Reporter SQL schema as in http://censusreporter.tumblr.com/post/55886690087/using-census-data-in-postgresql
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
state | county | tract | count | |
-------+--------+--------+------- | |
17 | 031 | 010400 | 1 | |
17 | 031 | 020702 | 1 | |
17 | 031 | 030101 | 1 | |
17 | 031 | 030102 | 1 | |
17 | 031 | 030103 | 1 | |
17 | 031 | 030104 | 1 | |
17 | 031 | 030601 | 1 | |
17 | 031 | 030604 | 1 | |
17 | 031 | 030706 | 1 | |
17 | 031 | 031300 | 1 | |
17 | 031 | 031400 | 1 | |
17 | 031 | 060800 | 1 | |
17 | 031 | 060900 | 1 | |
17 | 031 | 061902 | 1 | |
17 | 031 | 063200 | 1 | |
17 | 031 | 070101 | 1 | |
17 | 031 | 071400 | 1 | |
17 | 031 | 071500 | 1 | |
17 | 031 | 081202 | 1 | |
17 | 031 | 081403 | 1 | |
17 | 031 | 090200 | 1 | |
17 | 031 | 090300 | 1 | |
17 | 031 | 320600 | 1 | |
17 | 031 | 390700 | 1 | |
17 | 031 | 410100 | 1 | |
17 | 031 | 410900 | 1 | |
17 | 031 | 411000 | 1 | |
17 | 031 | 420100 | 1 | |
17 | 031 | 430102 | 1 | |
17 | 031 | 430700 | 1 | |
17 | 031 | 431400 | 1 | |
17 | 031 | 740400 | 1 | |
17 | 031 | 770500 | 4 | |
17 | 031 | 770602 | 3 | |
17 | 031 | 770700 | 3 | |
17 | 031 | 770800 | 2 | |
17 | 031 | 770902 | 2 | |
17 | 031 | 805600 | 1 | |
17 | 031 | 807900 | 1 | |
17 | 031 | 808100 | 1 | |
17 | 031 | 810400 | 2 | |
17 | 031 | 821402 | 2 | |
17 | 031 | 823304 | 3 | |
17 | 031 | 843900 | 1 | |
17 | 031 | 980000 | 7 | |
17 | 043 | 840000 | 2 | |
17 | 043 | 840801 | 1 |
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 g.state, g.county, g.tract, count(*) | |
from acs2011_5yr.geoheader g, | |
(select distinct state, county, tract from acs2011_5yr.geoheader where sumlevel = 80 and state = '17' and place = '14000') g2 | |
where g.state = g2.state | |
and g.county = g2.county | |
and g.tract = g2.tract | |
and g.sumlevel = 80 | |
and g.place != '14000' | |
group by g.state, g.county, g.tract | |
order by g.state, g.county, g.tract | |
; |
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
logrecno | state | county | tract | place | |
----------+-------+--------+--------+------- | |
6461 | 17 | 031 | 010400 | 99999 | |
7784 | 17 | 031 | 020702 | 43744 | |
6462 | 17 | 031 | 030101 | 99999 | |
6463 | 17 | 031 | 030102 | 99999 | |
6464 | 17 | 031 | 030103 | 99999 | |
6465 | 17 | 031 | 030104 | 99999 | |
6466 | 17 | 031 | 030601 | 99999 | |
6467 | 17 | 031 | 030604 | 99999 | |
6468 | 17 | 031 | 030706 | 99999 | |
6469 | 17 | 031 | 031300 | 99999 | |
6470 | 17 | 031 | 031400 | 99999 | |
6471 | 17 | 031 | 060800 | 99999 | |
6472 | 17 | 031 | 060900 | 99999 | |
6473 | 17 | 031 | 061902 | 99999 | |
6474 | 17 | 031 | 063200 | 99999 | |
6475 | 17 | 031 | 070101 | 99999 | |
6476 | 17 | 031 | 071400 | 99999 | |
6477 | 17 | 031 | 071500 | 99999 | |
6478 | 17 | 031 | 081202 | 99999 | |
6479 | 17 | 031 | 081403 | 99999 | |
7726 | 17 | 031 | 090200 | 57875 | |
7727 | 17 | 031 | 090300 | 57875 | |
6480 | 17 | 031 | 320600 | 99999 | |
6481 | 17 | 031 | 390700 | 99999 | |
6482 | 17 | 031 | 410100 | 99999 | |
6483 | 17 | 031 | 410900 | 99999 | |
6484 | 17 | 031 | 411000 | 99999 | |
6485 | 17 | 031 | 420100 | 99999 | |
6486 | 17 | 031 | 430102 | 99999 | |
6487 | 17 | 031 | 430700 | 99999 | |
6488 | 17 | 031 | 431400 | 99999 | |
8369 | 17 | 031 | 740400 | 54820 | |
7480 | 17 | 031 | 770500 | 19642 | |
7490 | 17 | 031 | 770500 | 23256 | |
7495 | 17 | 031 | 770500 | 51089 | |
7516 | 17 | 031 | 770500 | 99999 | |
7697 | 17 | 031 | 770602 | 19642 | |
7739 | 17 | 031 | 770602 | 65819 | |
7742 | 17 | 031 | 770602 | 99999 | |
7740 | 17 | 031 | 770700 | 65819 | |
7623 | 17 | 031 | 770700 | 65819 | |
7627 | 17 | 031 | 770700 | 99999 | |
7624 | 17 | 031 | 770800 | 68081 | |
7628 | 17 | 031 | 770800 | 99999 | |
7856 | 17 | 031 | 770902 | 53377 | |
7615 | 17 | 031 | 770902 | 53377 | |
7730 | 17 | 031 | 805600 | 57875 | |
7785 | 17 | 031 | 807900 | 43744 | |
7793 | 17 | 031 | 808100 | 53000 | |
7859 | 17 | 031 | 810400 | 57875 | |
7860 | 17 | 031 | 810400 | 99999 | |
6647 | 17 | 031 | 821402 | 10513 | |
6649 | 17 | 031 | 821402 | 99999 | |
8348 | 17 | 031 | 823304 | 01010 | |
8368 | 17 | 031 | 823304 | 48554 | |
8398 | 17 | 031 | 823304 | 99999 | |
6496 | 17 | 031 | 843900 | 99999 | |
7710 | 17 | 031 | 980000 | 19642 | |
7485 | 17 | 031 | 980000 | 19642 | |
7494 | 17 | 031 | 980000 | 23256 | |
7741 | 17 | 031 | 980000 | 65819 | |
7626 | 17 | 031 | 980000 | 68081 | |
7522 | 17 | 031 | 980000 | 99999 | |
7756 | 17 | 031 | 980000 | 99999 | |
8637 | 17 | 043 | 840000 | 05248 | |
8644 | 17 | 043 | 840000 | 23256 | |
8642 | 17 | 043 | 840801 | 05248 |
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 g.logrecno,g.state, g.county, g.tract, g.place | |
from acs2011_5yr.geoheader g, | |
(select distinct state, county, tract | |
from acs2011_5yr.geoheader | |
where sumlevel = 80 and state = '17' and place = '14000') g2 | |
where g.state = g2.state | |
and g.county = g2.county | |
and g.tract = g2.tract | |
and g.sumlevel = 80 | |
and g.place != '14000' | |
order by g.state, g.county, g.tract, g.place | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment