본문 바로가기

Algorithm/MySQL

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

문제

Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

Input Format

The STATION table is described as follows:

코드

  • Substring
Select distinct city
From Station
Where substring(city, 1, 1) NOT IN ('a','e','i','o','u')
  1. Station 테이블에서 city 이름의 첫글자가 모음으로 시작하지 않는 컬럼 출력
  2. 중복 금지
  • 정규표현식
SELECT distinct city
FROM station
WHERE city NOT REGEXP '^[aeiou].*'

뭔가 계속 비슷한 유형이긴 한데 오늘 10문제 풀어야하니까... 감사한 마음으로 푸는 중..😅

출처

반응형