์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[HackerRank] Asian Population (SQL/JOIN)

PROGRAMMING/Database

by koharin 2021. 2. 1. 11:56

๋ณธ๋ฌธ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ป Oracle ์ œ์ถœ์ฝ”๋“œ


select sum(A.POPULATION)
from CITY A
full outer join COUNTRY B
on A.CountryCode = B.Code
where B.CONTINENT = 'Asia';
select sum(A.POPULATION)
from CITY A
inner join COUNTRY B
on A.CountryCode = B.Code
where B.CONTINENT = 'Asia';
  • COUNTRY์™€ CITY ํ…Œ์ด๋ธ”์—์„œ

  • WHERE: CONTINENT๊ฐ€ 'Asia'์ธ 

  • SELECT: ๋ชจ๋“  ๋„์‹œ ์ธ๊ตฌ ์ˆ˜์˜ ํ•ฉ(SUM)

  • JOIN์„ ํ•  ๋•Œ๋Š” WHERE๋ฌธ์œผ๋กœ ์กฐ๊ฑด์„ ์ฃผ๊ธฐ ๋•Œ๋ฌธ์—, FULL OUTER JOIN์ด๋‚˜ INNER JOIN์ด๋‚˜ ์ƒ๊ด€์—†๋‹ค.

728x90
๋ฐ˜์‘ํ˜•

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ