새소식

SQL/해커랭크

[MySQL] Weather Observation Station 11

  • -

[문제]

Weather Observation Station 11 | HackerRank

 

Weather Observation Station 11 | HackerRank

Query a list of CITY names not starting or ending with vowels.

www.hackerrank.com


[문제 풀이]

Weather Observation Station 8 번 문제를 응용해서 풀어보자.

단, Not like 를 사용하니 기존 방식과 and 와 or 의 위치가 살짝씩 수정이 된다.


[코드]

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%') or (CITY NOT LIKE '%a' and CITY NOT LIKE '%e' and CITY NOT LIKE '%i' and CITY NOT LIKE '%o' and CITY NOT LIKE '%u')
ORDER BY CITY

'SQL > 해커랭크' 카테고리의 다른 글

[MySQL] Higher Than 75 Marks  (0) 2022.10.10
[MySQL] Weather Observation Station 12  (0) 2022.10.09
[MySQL] Weather Observation Station 10  (0) 2022.10.09
[MySQL] Weather Observation Station 9  (0) 2022.10.09
[MySQL] Weather Observation Station 8  (0) 2022.10.09
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.