Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions 4_soutions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ SELECT continent, name FROM world x WHERE name <= ALL(SELECT name FROM world y W

--9. Find the continents where all countries have a population <= 25000000. Then find the names of the countries associated with these continents. Show name, continent and population.

SELECT name, continent, population FROM world WHERE continent IN (SELECT continent FROM world x WHERE 25000000 >= (SELECT MAX(population) FROM world y WHERE x.continent = y.continent));
or
SELECT y.name, y.continent, y.population
FROM world AS y
JOIN
(SELECT continent,max(population)
SELECT name, continent, population
FROM world
GROUP BY continent
HAVING max(population) <= 25000000) AS x
ON y.continent = x.continent
WHERE continent IN (
SELECT continent
FROM world
GROUP BY continent
HAVING MAX(population) <= 25000000
)