인프런 강의 <데이터 분석을 위한 고급 SQL>을 듣고, 중요한 점을 정리한 글입니다.
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:
SELECT DISTINCT city
FROM station
WHERE city REGEXP '.^*[aeiou]$'
: 이렇게 풀어도 정답으로 패스된다. 선생님 풀이와 조금 다른 문법이다.
SELECT DISTINCT city
FROM station
WHERE city REGEXP '.*[aeiou]$'
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].*$'
: 정규표현식 테스트 사이트에서는 이렇게 테스트했을 때, 통과되는데 해커랭크에서는 틀렸다고 나온다.
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[aeiou].*[aeiou]$'
Query the list of CITY names from STATION that do not start 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.
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[^aeiou]'
: 이렇게 표현할 수도 있다. 해커랭크에서 정답처리된다.
SELECT DISTINCT city
FROM station
WHERE city NOT REGEXP '^[aeiou].*'