Question
SQL List all zip codes along with a column that classifies their gender distribution in 2018. To calculate the distribution, take the female population and
SQL
List all zip codes along with a column that classifies their gender distribution in 2018. To calculate the distribution, take the female population and divide by the total population. Then, for the classification, if the % female is greater than 60%, call it "predominantly female". If it is below 40%, call it "predominantly male." For everything else, input "evenly distributed". (As a hint, include a new field that calculates the gender distribution, and then use that field in your CASE statement.) In the results, include the zip code, gender distribution (%), and the gender distribution classification. Finally, only include zip codes with a total population of at least 1000 people and sort by the zip code in ascending order.
FROM CENSUS_BY_ZIP_CODE
ZIP_CODE VARCHAR (5) NOT NULL, REPORTING_YEAR NUMBER (38,), HOUSEHOLDS NUMBER (38,0), POPULATION_TOTAL NUMBER (38,0), POPULATION_MALE NUMBER (38,0), POPULATION_FEMALE NUMBER (38,0), MEDIAN_AGE NUMBER (3,1), HOUSING_UNITS_TOTAL NUMBER(38,0), HOUSING_UNITS_OCCUPIED NUMBER (38,0)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started