首页 > 技术文章 > sqlzoo.net刷题3

winters1992 2016-08-28 05:57 原文

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.

这道题,我一开始理解错了,我以为是整个洲人口 <= 25000000,然后列出这些洲所在的国家以及人口

后来select几遍之后才发现理解错题意了,英语果然还是硬伤,题目我是看了stackoverflow之后才理解的,

完整并且翻译应该是下面:

找到那些洲,这些洲下面每个国家的人口都<= 25000000,然后列举出这些洲的国家的名字以及他们的人口

SELECT name, continent, population 
FROM world w
WHERE NOT EXISTS (                  
   SELECT *
   FROM world nx
   WHERE nx.continent = w.continent 
   AND nx.population > 25000000   
   );

这个子查询是反查

推荐阅读