본문 바로가기
SQL

[HackerRank SQL] Weather Observation Station 6 (Oracle)

by 동글엘라 2024. 3. 30.

Weather Observation Station 6

 

Problem

 

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.

(STATION에서 모음(a, e, i, o, u)으로 시작하는 도시(CITY) 이름의 목록을 조회하시오. 결과에는 중복이 포함되어서는 안 됨.)

Input Format

The STATION table is described as follows:

Solution(Oracle)

 

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%');

LIKE 연산자와 와일드카드

  • LIKE 연산자
    : 일부 문자열이 포함된 데이터를 조회할 때 사용
    • 'AND'와 'OR'을 사용해서 LIKE 조건을 결합할 수 있다. 
  • 와일드 카드 (_), (%)
종류 의미
_ (underscore) 어떤 값이든 상관없이 한 개의 문자 데이터를 의미
% (precent sign) 길이와 상관없이(문자 없는 경우도 포함) 모든 문자 데이터를 의미

 

 

Weather Observation Station 6 | HackerRank

Query a list of CITY names beginning with vowels (a, e, i, o, u).

www.hackerrank.com