SQLZOO趣题解

因为看过参考答案所以觉得自己的这些解答很有趣啊。我是sql集合党 XD

SELECT within SELECT

8

First country of each continent (alphabetically): List each continent and the name of the country that comes first alphabetically.

SELECT continent, MIN(name) AS name
FROM world
GROUP BY continent

9

Difficult Questions That Utilize Techniques Not Covered In Prior Sections: 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 
  (
    SELECT continent,MAX(population) AS count
    FROM world
    GROUP BY continent
  ) AS continentTable
  WHERE continentTable.count<=25000000
) 

 

你可能感兴趣的:(SQL)