SQLZOO练习笔记-Select within select tutorial

SELECT name FROM world
WHERE population > (SELECT population FROM world WHERE name=‘Russia’)

select name from world
where continent = ‘Europe’
and gdp/population > (select gdp/population from world
where name = ‘United Kingdom’)

select name, continent from world
where continent not in (‘Argentina’, ‘Australia’)
order by name

select name, population from world
where population between (select population+1 from world
where name = ‘Canada’) and (select population-1 from world
where name = ‘Poland’)

select name, concat(round(100*population/(select population from world
where name = ‘Germany’),0),’%’) from world
where continent = ‘Europe’

select name from world
where gdp > (select max(gdp) from world
where continent = ‘Europe’)

select continent, name, area from world
where area in (select area from(select continent,max(area) as area from world
group by continent) t)

select * from (select continent, name from world
order by name) t
group by continent

select name, continent, population from world
where continent not in (
select continent from world
where population > 25000000
group by continent)

select name,continent from world x
where x.population/3 >= all(select population from world y where x.continent=y.continent and x.name!=y.name and y.population>0)

特别说明:第十题答案来自于[link]https://www.cnblogs.com/brucemengbm/p/7191649.html
本来自己也差不多这么写的但是不知道哪里出错就把代码给删了…还是应该要保留好自己每次写的代码才行。

猜你喜欢

转载自blog.csdn.net/yizhu007_/article/details/82945220