首页 > 代码库 > sqlzoo转
sqlzoo转
http://m.blog.csdn.net/article/details?id=50504578
SELECT within SELECT Tutorial
6.Which countries have a GDP greater than every country in Europe? [Give the name only.] (Some countries may have NULL gdp values)
select name from world where gdp >ALL(select gdp from world where gdp > 0 and continent=‘Europe‘)
7.Find the largest country (by area) in each continent, show the continent, the name and thearea:
SELECT continent, name, area FROM world xWHERE x.area >=ALL(SELECT y.area FROM world yWHERE y.continent=x.continentAND area>0)
select continent,name,area from world where area in(SELECT max(area) FROM world group by continent)
8.List each continent and the name of the country that comes first alphabetically.分组后,每组数据中的第一行
select continent,name from world as x where x.name=(select y.name from world as y where y.continent=x.continent order by name limit 1)
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,populationfrom world xwhere 25000000>=all(select population from world ywhere x.continent=y.continent and population>0)
sqlzoo转
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。