HackerRank- Weather Observation Station 6,7,8,9
REGEXP 관련 정리된 게시물
Weather Observation Station 6📝
➡️ STATION 테이블, 조건 : city a%, e% , i%, o%, u% -> 출력 : 중복되지 않는 city
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or 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.
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%');
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[aeiou]';
Weather Observation Station 7📝
➡️ STATION 테이블, 조건 : city %a, %e , %i, %o, %u -> 출력 : 중복되지 않는 city
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.
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');
SELECT DISTINCT city
FROM station
WHERE city REGEXP '[aeiou]$';
Weather Observation Station 8📝
➡️ STATION 테이블, 조건 : city a%(aeiou),e%(aeiou) ,i%(aeiou),o%(aeiou),u%(aeiou) -> 출력 : 중복되지 않는 city
ex )Acme , Aguanga, Alba, Aliso Viejo, Alpine
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]'and city REGEXP'[aeiou]$';
SELECT DISTINCT city
FROM station
WHERE REGEXP_LIKE (city,'^a|^e|^i|^o|^u') AND REGEXP_LIKE (city,'a$|e$|i$|o$|u$');
SELECT DISTINCT city
FROM station
WHERE REGEXP_LIKE (city,'^[aeiou]') AND REGEXP_LIKE (city,'[aeiou]$');
SELECT DISTINCT city
FROM station
WHERE REGEXP_LIKE (city,'^[aeiou].*[aeiou]$');
Weather Observation Station 9📝
➡️ STATION 테이블, 조건 : a,e,i,o,u로 시작되지 않는 city 이름 -> 출력 : 중복되지 않는 city
-> Weather Obseration Station 6번에 not 또는 ^을 붙인다.
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 NOT (city LIKE 'A%'
OR city LIKE 'E%'
OR city LIKE 'I%'
OR city LIKE 'O%'
OR city LIKE 'U%');
SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[^aeiou]';