Answers for "--Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents."

0

--Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents.

SELECT name, 
       region 
FROM   bbc x 
WHERE  population > 
       -- this sub query finds each neighbour (not including itself) and returns the max populations multiplied by 3
       (SELECT 3 * MAX(population) 
        FROM   bbc y 
        WHERE  x.region = y.region 
               AND x.name <> y.name)
Posted by: Guest on August-15-2021
0

--Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents.

SELECT name, 
       region, 
       population 
FROM   bbc x 
WHERE  population < ALL 
       -- the ALL keyword allows comparison to be made against all the values in a list 
       -- this sub query finds each country that belongs to a region with populations less than 25 million and returns this as a list
       (SELECT population 
        FROM   bbc y 
        WHERE  y.region = x.region 
               AND population > 25000000)
Posted by: Guest on August-15-2021

Code answers related to "--Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents."

Browse Popular Code Answers by Language