SQL combined SELECT statement SQL combined SELECT statement sql sql

SQL combined SELECT statement


The following code worked for me:

SELECT name, continent, population FROM world x  WHERE 25000000>=ALL (SELECT population FROM world y                         WHERE x.continent=y.continent                         AND population>0)


SELECT name, continent, population FROM world wWHERE NOT EXISTS (                  -- there are no countries   SELECT *   FROM world nx   WHERE nx.continent = w.continent -- on the same continent   AND nx.population > 25000000     -- with more than 25M population    );


SELECT name, continent, population FROM world x WHERE 25000000 > ALL(SELECT population                      FROM world y                      WHERE y.continent = x.continent                      )

The 'ALL' part compares the population of all the countries in a continent with 25000000 and if it less than 25000000, it prints names, population of all countries in it.