Created
February 8, 2013 22:05
-
-
Save janl/4742336 to your computer and use it in GitHub Desktop.
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
# list by how many inhabitants all in all | |
select district, sum(quantity) from inhabitants group by district order by sum(quantity); | |
# list by how many women per district | |
select district, sum(quantity) from inhabitants where gender = 'f' group by district order by sum(quantity); | |
# list by how many children per district pre-school (0-5) | |
select district, sum(quantity) from inhabitants where age_low = '0' group by district order by sum(quantity); | |
# is indeed Prenzlauer Berg the district with the most children implying as many parents as well? | |
# absolute numbers say yes - more than in Neukölln - but in | |
# percentages? | |
select district, sum(quantity) from inhabitants where age_low = '0' group by district order by sum(quantity); | |
# list by how many children per district 0-10 years old | |
select district, sum(quantity) from inhabitants where age_low = '0' or age_high = '10' group by district order by sum(quantity); | |
# list number of inhabitants without german nationality | |
select district, sum(quantity) from inhabitants where nationality = 'A' group by district order by sum(quantity); | |
# due to jus sanguin same goes for children: | |
select district, sum(quantity) from inhabitants where nationality = 'A' and age_low = '0' or age_high = '10' group by district order by sum(quantity); | |
# list in what district live the most old women | |
select district, age_low, sum(quantity) from inhabitants where age_low = '95' and gender = 'f' group by district, age_low order by sum(quantity); | |
# list female percentages for every district: | |
select district, round(cast(sum(case when gender = 'f' then quantity end) as decimal)/sum(quantity)*100) as prozentweibchen, sum(quantity) from inhabitants group by district order by prozentweibchen; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment