我正在尝试学习一些 SQL,所以我一直在搞乱示例世界模式。对于此查询,目标是针对每个大陆检索预期寿命大于该大陆平均水平的国家/地区的首都。
下面的代码是我的尝试,但我在 where 语句中收到1111 错误。任何帮助将非常感激!
SELECT continent AS Continent,
city.name AS Capital
FROM city,
country c1
WHERE c1.capital = city.id
AND avg(LifeExpectancy) <
(SELECT avg(LifeExpectancy)
FROM country c2
WHERE c2.continent = c1.continent );