몸과 마음이 건전한 SW 개발자

[HackerRank-MSSQL] 해커랭크 basic select Weather Observation Station 11 본문

SQL/MSSQL

[HackerRank-MSSQL] 해커랭크 basic select Weather Observation Station 11

스위태니 2026. 4. 17. 14:04

문제 링크

https://www.hackerrank.com/challenges/weather-observation-station-11/problem?isFullScreen=true

 

Weather Observation Station 11 | HackerRank

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

www.hackerrank.com

정답 코드

select distinct city from station where city not like '[aeiou]%[aeiou]';

풀이 과정

  • city의 앞 문자가 a e i o u로 시작하지 않고 뒷 문자가 a e i o u로 끝나지 않고 라는 명제가 있다.
    • '[^aeiou]%' and '%[^aeiou]'
  • 이 명제를 대우로 표현하면 a e i o u로 시작하고 a e i o u로 끝나는 city가 된다.
    • '[aeiou]%[aeiou]'
  • 위의 대우 명제를 not like로 부정하면 
    • not like '[aeiou]%[aeiou]'가 된다.

느낀점

  • 명제, 역, 이, 대우에 대한 것을 배웠지만 언제 써먹을까 생각했다.
  • 마침 좋은 문제 같아서 기록으로 남긴다.