Algorithm/SQL Query test
[MySQL] HackerRank - Weather Observation Station 9
๊ฐ์ ๐ฅ
2021. 7. 22. 21:44
๋ฐ์ํ
๋ฌธ์
https://www.hackerrank.com/challenges/weather-observation-station-9/problem
Weather Observation Station 9 | HackerRank
Query an alphabetically ordered list of CITY names not starting with vowels.
www.hackerrank.com
Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
์ ๋ต
SELECT DISTINCT CITY
FROM STATION
WHERE CITY NOT LIKE 'A%'
AND CITY NOT LIKE 'E%'
AND CITY NOT LIKE 'I%'
AND CITY NOT LIKE 'O%'
AND CITY NOT LIKE 'U%'
์ฌ๊ธฐ์ AND ๊ฐ ์๋๋ผ OR์ ์จ์ ์๊ฐ์ ๋บ๊ฒผ๋ค. NOT LIKE๋๊น AND๋ก ์ฐ๊ฒฐํด์ฃผ๋๊ฒ ๋ง๋ค.... A๋ก ์์ํ์ง๋ ์๊ณ , E๋ก ์์ํ์ง๋ ์๊ณ ... ์ด๋ ๊ฒ ๋๋ ๊ฑฐ๋๊น!
์ด์ ์์์ ๋ฐฐ์ ๋ ์ ๊ท์์ ํ์ฉํด์ ๋ค์ ํ์ด๋ณด๊ฒ ๋ค.
SELECT DISTINCT CITY
FROM STATION
WHERE CITY NOT REGEXP '^[aeiou]'
-- ^๋ ์์์ ์๋ฏธ!! AEIOU๋ก ์์ํ์ง ์๋ ๊ฒ์ ๊ณจ๋ผ๋ผ
๋ฐ์ํ