https://www.hackerrank.com/challenges/weather-observation-station-12/problem?isFullScreen=true
모음으로 시작하지 않거나, 끝나지 않는 도시의 이름을 조회하는 문제입니다. 조회 할때 중복으로 된 단어는 제외하고 불러와야하는데요.
WHERE절에서 NOT LIKE를 이용해서 모음으로 시작하지 않는 도시와, 끝나지 않는 도시의 이름을 조회합니다.
SELECT *
FROM station
WHERE city NOT LIKE ('i%') AND
city NOT LIKE ('a%') AND
city NOT LIKE ('e%') AND
city NOT LIKE ('o%') AND
city NOT LIKE ('u%') AND
city NOT LIKE ('i%') AND
city NOT LIKE ('%a') AND
city NOT LIKE ('%e') AND
city NOT LIKE ('%o') AND
city NOT LIKE ('%u') AND
city NOT LIKE ('%i')
DISTINCT를 이용해서 중복을 제거해서 도시이름을 불러오면 정답입니다.
SELECT DISTINCT city
FROM station
WHERE city NOT LIKE ('i%') AND
city NOT LIKE ('a%') AND
city NOT LIKE ('e%') AND
city NOT LIKE ('o%') AND
city NOT LIKE ('u%') AND
city NOT LIKE ('i%') AND
city NOT LIKE ('%a') AND
city NOT LIKE ('%e') AND
city NOT LIKE ('%o') AND
city NOT LIKE ('%u') AND
city NOT LIKE ('%i')