๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Programming/SQL

[HackerRank] Basic Join : Average Population of Each Continent (MySQL)

1. ๋ฌธ์ œ ์„ค๋ช…

๋ฌธ์ œ ๋งํฌ

2. ์ฝ”๋“œ

SELECT O.CONTINENT, FLOOR(AVG(C.POPULATION))
FROM CITY AS C
JOIN COUNTRY AS O ON C.COUNTRYCODE = O.CODE
GROUP BY O.CONTINENT;
  • FLOOR(2.687) : ์†Œ์ˆ˜ ์ฒซ์งธ์ž๋ฆฌ์—์„œ ๋ฒ„๋ฆผ 2
  • ROUND(2.687) : ์†Œ์ˆ˜ ์ฒซ์งธ์ง€๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผ 3
  • CEIL(2.687) : ์†Œ์ˆ˜ ์ฒซ์งธ์ž๋ฆฌ์—์„œ ์˜ฌ๋ฆผ 3
  • ROUND(2.387, 2) : ์†Œ์ˆ˜ ์…‹์งธ์ž๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผ 2.39
  • ROUND(5961.6, -2) : ์‹ญ์˜์ž๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผ 6000

3. ์ฐธ๊ณ 

https://m.blog.naver.com/emoney01/221444384017