HAZEL

[SQL : 정규표현식 ] HackerRank : Weather Observation Station 7 / 8 본문

DATA ANALYSIS/SQL

[SQL : 정규표현식 ] HackerRank : Weather Observation Station 7 / 8

Rmsid01 2021. 5. 16. 18:08

Weather Observation Station 7


>> 문제

Query the list of CITY names ending with vowels (a, e, i, o, 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'

 

 

>> 정규표현식을 사용해서 푸는 법 

SELECT DISTINCT city
FROM station
WHERE city REGEXP '.*[aeiou]$' 

 

' $ '  :  마지막 글자일 때, 매치한다는 의미이다. 

' * '  : 여러 문자를 가짐을 의미한다. 

https://www.hackerrank.com/challenges/weather-observation-station-7/problem

 

Weather Observation Station 7 | HackerRank

Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION.

www.hackerrank.com

 

 

Weather Observation Station 8


>> 문제

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. 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 REGEXP '^[aeiou].*[aeiou]$'

https://www.hackerrank.com/challenges/weather-observation-station-8/problem?h_r=next-challenge&h_v=zen 

 

Weather Observation Station 8 | HackerRank

Query CITY names that start AND end with vowels.

www.hackerrank.com