SQL
[HackerRank] Weather Observation Station 11
rubyda
2021. 10. 22. 07:18
728x90
Query the list of CITY names from STATION that either do not start with vowels or do not end with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:
/*
문자열 함수 활용
*/
SELECT
DISTINCT city
FROM station
WHERE
LEFT(city,1) not in ('a', 'e', 'i', 'o', 'u')
OR RIGHT(city,1) not in ('a', 'e', 'i', 'o', 'u')
/*
정규 표현식 활용
*/
SELECT
DISTINCT city
FROM station
WHERE
city REGEXP '^[^aeiou]' OR city REGEXP '[^aeiou]$'