Mysql 世界数据库演习

Mysql 世界数据库演习,mysql,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='eu

欧洲城市哪个人口的缺陷最接近欧洲人口的中位数

我尝试使用这段代码,但子查询中的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;
从城市中选择城市名称、城市人口
加入国家
关于city.countrycode=country.code和country.continent='europe'
其中city.population
选择city.name,city.population from city
加入国家
关于city.countrycode=country.code和country.continent='europe'
其中city.population<(选择平均值(国家人口)
哪个国家。大陆(欧洲)
按城市排序;

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

Select city.name,city.population from city
Join country
On city.countrycode=country.code and country.continent=’europe’
Where (select avg(country.population))>city.population
Order by city.population desc
Limit 1;

将选择置于平均值(国家人口)
之前。这是一个子查询,需要以SELECT开头。@leonardo_palma Middian意思是它的可能重复项甚至与selectOk不起作用。我找到了解决方案,我的错误是重复where子句,同时我已经在join中声明了它!我看不出这个答案能回答这个问题。
Select city.name,city.population from city
Join country
On city.countrycode=country.code and country.continent=’europe’
Where (select avg(country.population))>city.population
Order by city.population desc
Limit 1;