본문 바로가기

Algorithm/MySQL

[해커랭크(HackerRank)] Weather Observation Station 12 (MySQL)

문제

Query the list of CITY names from STATION that do not start with vowels and do not end 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 city NOT LIKE '%A'
AND city NOT LIKE '%E'
AND city NOT LIKE '%I'
AND city NOT LIKE '%O'
AND city NOT LIKE '%U'

 

풀이

  1. STATION 테이블의 city 이름에 앞글자와 뒷글자에 모음이 포함되지 않는 데이터만 조회
  2. 데이터가 중복되지 않아야함
반응형