본문 바로가기

Algorithm/MySQL

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

문제

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION.
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 LIKE 'a%'
OR city LIKE 'e%'
OR city LIKE 'i%'
OR city LIKE 'o%'
OR city LIKE 'u%'

 

풀이

  1. STATION 테이블에서 city 이름이 모음으로 시작하는 데이터만 조회
  2. 결과가 중복되지 않아야함
반응형