Algorithm/SQL
[SQL][HackerRank] Weather Observation Station 12
융무
2020. 6. 9. 10:09
Weather Observation Station 12 | HackerRank
Query an alphabetically ordered list of CITY names not starting and ending with vowels.
www.hackerrank.com
Query the list of CITY names from STATION that do not start with vowels and 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.
- query CITY names ==> SELECT CITY
- from STATION table ==> FROM STATION
- do not start and end with vowels ==> WHERE CITY REGEXP ‘^[^aeiou].*[^aeiou]$’
- do not contain duplicates ==> SELECT DISTINCT CITY
select distinct city
from station
where (left(city,1) not in ('a','e','i','o','u')
and
right(city,1) not in ('a','e','i','o','u'));
SELECT DISTINCT CITY FROM STATION WHERE CITY REGEXP '^[^aeiou].*[^aeiou]$';
SELECT * FROM TEST WHERE regexp_like(text, '[a-z][0-9]');
[a-z], [0-9]는 소문자 전체와 0부터9까지의 숫자를 나타냅니다.