Potato
์•ˆ๋…•ํ•˜์„ธ์š”, ๊ฐ์žก๋‹ˆ๋‹ค?๐Ÿฅ” ^___^ ๐Ÿ˜บ github ๋ฐ”๋กœ๊ฐ€๊ธฐ ๐Ÿ‘‰๐Ÿป

Algorithm/SQL Query test

[MySQL] HackerRank - Weather Observation Station 3

๊ฐ์ž ๐Ÿฅ” 2021. 7. 20. 03:08
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

https://www.hackerrank.com/challenges/weather-observation-station-3/problem

 

Weather Observation Station 3 | HackerRank

Query a list of unique CITY names with even ID numbers.

www.hackerrank.com

Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer. The STATION table is described as follows.

 

์ •๋‹ต

๋ฌธ์ œ์—์„œ ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ํ‘œ์‹œํ•ด๋‘” ๋ถ€๋ถ„์„ ๋ณด์ž. "EVEN" ID NUMBER... ์ง์ˆ˜๋ฅผ ๋œปํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ EVEN NUMBER / ODD NUMBER ์ด๊ฑฐ!!! ์ด๊ฑฐ ์บ์น˜ ๋ชปํ•ด์„œ ๋ฌธ์ œ๋ฅผ ๋ชป์•Œ์•„๋“ฃ๊ณ , ํŒŒํŒŒ๊ณ  ๋ฒˆ์—ญ์„ ๋Œ๋ ธ๋Š”๋ฐ ํ•ด์„์„ ์ด์ƒํ•˜๊ฒŒ ํ•˜๋Š” ๋ฐ”๋žŒ์— ํ•˜๋‚˜์˜ CITY์ง€๋งŒ ๋‘๊ฐœ ์ด์ƒ์˜ ID๋ฅผ ๊ฐ–๋Š” ๊ฒƒ๋“ค์„ ์ฐพ๊ณ  ์žˆ์—ˆ๋‹ค... ๋‹น์—ฐํžˆ ์˜ค๋‹ต์ผ์ˆ˜๋ฐ–์—... 

์ง์ˆ˜์ธ ์•„์ด๋””๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด ๋‚˜๋ˆ„๊ธฐ(%) ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค. ํŒŒ์ด์ฌ๊ณผ ๋™์ผํ•˜๊ฒŒ (%๋Š” ๋‚˜๋จธ์ง€๊ฐ€์ถœ๋ ฅ๋˜๊ณ , /๋Š” ๋ชซ์ด ํ‘œํ˜„๋œ๋‹ค. ๋‹จ MYSQL์—์„œ๋Š” ๋ชซ๋ง๊ณ  ์†Œ์ˆซ์ ์œผ๋กœ ๋‚˜๋ˆ ์ง„ ์ •ํ™•ํ•œ ๊ฐ’์ด ํ‘œํ˜„๋œ๋‹ค.)

SELECT DISTINCT CITY
FROM STATION
WHERE (ID%2) = 0

 

๋ฐ˜์‘ํ˜•