Milky's note

[HackerRank](E) Weather Observation Station 7 본문

SQL/SQL 코딩 테스트-HackerRank

[HackerRank](E) Weather Observation Station 7

밀뿌 2022. 3. 16. 17:07

https://www.hackerrank.com/challenges/weather-observation-station-7/problem?isFullScreen=true 

 

Weather Observation Station 7 | HackerRank

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

www.hackerrank.com

 

[문제]

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.

 

[답]

- mysql

select distinct(city) from station
where right(city,1) in ('a','e','i','o','u');
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';

앞의 6번문제와 반대로 a, e, i, o, u로 끝나는 도시 이름을 찾는 것 이므로

left를 맨 끝 글자인 right 1로 변경하여 조회한다.

Comments