SELECT A.CONTINENT, FLOOR(AVG(B.POPULATION))
FROM COUNTRY A
JOIN CITY B
ON A.CODE = B.COUNTRYCODE
GROUP BY A.CONTINENT;
SELECT: ๋ชจ๋ ๋๋ฅ์ ์ด๋ฆ(COUNTRY.Continent)๊ณผ ๋์ ์ธ๊ตฌ์์ ํ๊ท (CITY.Population)์ ์กฐํํ๋ค. ์ด๋ ํ๊ท ์ ๊ฒฐ๊ณผ๋ณด๋ค ์๊ฑฐ๋ ๊ฐ์ ์ต๋ ์ ์์ด๋ค. (FLOOR)
FROM ~ JOIN: COUNTRY์ CITY ํ ์ด๋ธ์์
ON: CITY.CountryCode์ COUNTRY.Code๊ฐ ๋งค์นญ๋๋ค.
GROUP BY: CONTINENT๋ณ๋ก ํ๊ท ์ ๊ตฌํด์ผ ํ๋ฏ๋ก CONTINENT๋ก ๊ทธ๋ฃนํํ๋ค.
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฃจ์์ ์๋ผ ์ฐพ๊ธฐ (SQL String, Date / Oracle) (0) | 2021.02.16 |
---|---|
[HackerRank] The Report (SQL/JOIN) (0) | 2021.02.06 |
[HackerRank] African Cities (SQL/JOIN) (0) | 2021.02.01 |
[HackerRank] Asian Population (SQL/JOIN) (0) | 2021.02.01 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ณดํธ์์์ ์ค์ฑํํ ๋๋ฌผ (SQL/JOIN) (0) | 2021.01.30 |