Analysis & Visualization/SQL
[SQL] HackerRank - Weather Observation Station 11
statsbymin
2022. 7. 28. 07:32
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:

where LAT_N is the northern latitude and LONG_W is the western longitude.
문제요약
더보기
STATION 테이블에서 CITY컬럼의 시작과 끝이 모음이 아닌 리스트들을 중복 없이 출력
풀이
select distinct city from station
where city regexp '^[^aeiou]' or
city regexp '[^aeiou]$';
- distinct 문으로 중복 제거
- ^[ ]는 시작, []$는 끝 패턴을 찾음
- [^ ]는 not을 의미. ( = city not regexp '^[aeiou]')