Screen Link:
https://app.dataquest.io/m/463/joining-data-in-sql/8/challenge-complex-query-with-joins-and-subqueries
My Code:
SELECT name,urban_pop,facts.population as total_pop,Round(cast(urban_pop as float)/facts.population,6) as urban_pct from facts join (SELECT facts_id,SUM(population) as urban_pop from cities group by facts_id) as city on facts.id=city.facts_id where urban_pct>0.5 ORDER by urban_pct ASC
What I expected to happen:
A table consisting of country name, urban population, total population and percentage of population as shown in the question
What actually happened:
I got the same result as expected but it doesn’t accept the submission