SQLZOO(SELECT within SELECT Tutorial)Writeup

来源:互联网 发布:工艺流程软件软件 编辑:程序博客网 时间:2024/04/28 05:21

转载自SQLZOO(SELECT within SELECT Tutorial)Writeup

1.

SELECT name FROM world  WHERE population >     (SELECT population FROM world      WHERE name='Russia')

2.

SELECT name FROM world     WHERE continent = 'Europe' AND gdp/population > (SELECT gdp/population FROM world WHERE name = 'United Kingdom')

3.

select name,continent from world     where (continent =(select continent from world where name='Argentina'))        or (continent =(select continent from world where name='Australia'))order by name

4.

select name,population from world where population>(select population from world where name ='Canada') and population<(select population from world where name='Poland')

5.

select name,CONCAT(ROUND(100*population/(select population from world where name='Germany')),'%') from world where continent='Europe'

6.

select name from world where gdp > ALL(select gdp from world where gdp>0 and continent='Europe')

这里必须要gdp>0

7.

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

8.

select continent,name from world x     where x.name=(select y.name from world y where y.continent=x.continent order by name limit 1)

9.

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

10.

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)
0 0