This repository was archived by the owner on Jul 21, 2019. It is now read-only.

Description
I'm having trouble understanding what is needed to satisfy the following query:
"Some countries have populations more than three times that of any of their
neighbors (in the same continent). Give the countries and continents."
RSpec is asking for
expect(large_neighbors).to contain_exactly(
["Brazil", "South America"],
["China", "Asia-Pacific"],
["India", "South Asia"]
)
I feel that
SELECT name, continent FROM countries first
WHERE population > 3 * (SELECT avg(population)
FROM countries second where first.continent = second.continent
GROUP BY continent);
should satisfy this answer.
The output is as follows:
name | continent
------------------------------+---------------
Brazil | South America
China | Asia-Pacific
Cuba | Americas
Democratic Republic of Congo | Africa
Egypt | Middle East
Ethiopia | Africa
France | Europe
Germany | Europe
Guatemala | Americas
India | South Asia
Indonesia | Asia-Pacific
Iran | Middle East
Italy | Europe
Nigeria | Africa
Russia | Europe
South Africa | Africa
Turkey | Europe
United Kingdom | Europe
(18 rows)
For instance,
select population from countries where name = 'Turkey'; (73300000)
is higher than the average of other European countries:
select 3 * avg(population) from countries where continent = 'Europe'; (17404680.851063829787)