世界数据库练习

时间:2015-11-28 14:03:02

标签: mysql

人口最接近欧洲人口中位数的欧洲城市?

我尝试使用此代码,但是我总是在子查询中的where条件中出错

Select city.name,city.population from city
join country
on city.countrycode=country.code and country.continent='europe'
where city.population<(
avg(country.population)
where country.continent='europe')
order by city.population desc;

2 个答案:

答案 0 :(得分:1)

Select city.name,city.population from city
join country
on city.countrycode=country.code and country.continent='europe'
where city.population < (select avg(country.population)
where country.continent='europe')
order by city.population desc;

答案 1 :(得分:0)

好的,我找到了解决方案,我的错误是重复了where子句,同时我已经在连接中声明了它:

file1 = input("Enter the name of the first file: ")
file1_open = open(file1, encoding=guess_encoding(file1))
file1_content = file1_open.read()