Screen Link: https://app.dataquest.io/m/179/joining-data-in-sql/7/combining-joins-with-subqueries
Your Code:
SELECT cities.name capital_city,
facts.name country, cities.population population
FROM facts
INNER JOIN (
SELECT * FROM cities
WHERE capital = 1
AND population > 10000000
) ON cities.facts_id=facts.id
ORDER BY 3 DESC;
What I expected to happen: Get a table with capital city, country name, and population; capital cities with populations of over 10 million ordered from largest to smallest
What actually happened:
(sqlite3.OperationalError) no such column: cities.name
[SQL: SELECT cities.name capital_city, facts.name country, cities.population population FROM facts f INNER JOIN ( SELECT * FROM cities WHERE capital = 1 AND population > 10000000 ) c ON cities.facts_id=facts.id ORDER BY 3 DESC;]
(Background on this error at: http://sqlalche.me/e/e3q8)```
Other details: Hows my code wrong?