https://sqlzoo.net/wiki/SELECT_within_SELECT_Tutorial
SELECT within select tutorial
--no1
select name from world
where population > (select population from world
where name='Russia')
--no2
select name
from world
where continent='Europe' and (gdp/population) >
(select gdp/population from world
where name='United Kingdom')
--no3
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;
SELECT name, continent
FROM world
WHERE continent IN (SELECT continent FROM world WHERE name IN ('Argentina', 'Australia'))
ORDER BY name
--no4
select name, population from world
where
population >
(select population from world where name = 'Canada')
and
population <
(select population from world where name = 'Poland')
--no5
select name, concat(ROUND((population/
(select population from world where name = 'Germany'))*100,0),'%')
as Percentage
from world where continent = 'Europe';
--no6
select name from world
where
gdp > all
(select gdp from world where gdp > 0 and continent='Europe');
--no7
SELECT continent, name, area
FROM world x
WHERE area >= ALL
(SELECT area FROM world y WHERE y.continent=x.continent AND area>0)
--no8
SELECT continent, name
FROM world x
WHERE name <= ALL(SELECT name FROM world y WHERE y.continent = x.continent)
--no9
select
name, continent, population
from world x
where 25000000 >=
all(select population from world y
where x.continent = y.continent and population > 0)
--no10
SELECT name, continent
FROM world x
WHERE population >
ALL(SELECT population*3 FROM world y
WHERE x.continent = y.continent AND population > 0 AND y.name != x.name)
'MySQL' 카테고리의 다른 글
sqlzoo.net 답 (SELECT from Nobel Tutorial) (0) | 2020.09.01 |
---|---|
sqlzoo.net 답 (SELECT from WORLD Tutorial) (0) | 2020.09.01 |
sqlzoo.net 답 (SELECT basics) (0) | 2020.09.01 |
MySQL server PID file could not be found! 이슈 해결 (0) | 2020.08.26 |
MySQL 설치 (MAC with Homebrew) (0) | 2020.08.26 |