HackerRank- Weather Observation Station 6,7,8,9
REGEXP 관련 정리된 게시물
REGEXP,REGEXP_LIKE,REGEXP_INSTR,REGEXP_SUBSTR,REGEXP_REPLACE()
참고 블로그 : https://goodteacher.tistory.com/232 MySQL :: MySQL 8.0 Reference Manual :: 12.8.2 Regular Expressions 12.8.2 Regular Expressions Table 12.14 Regular Expression Functions and Operato..
coooco.tistory.com
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]';
'SQL > HackerRank' 카테고리의 다른 글
댓글
이 글 공유하기
다른 글
-
Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)
Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)
2022.09.12 -
HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names
HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names
2022.09.12 -
HackerRank-Japanese Cities' Attributes, Japanese Cities' Names, Weather Observation Station 1, Weather Observation Station 3, Weather Observation Station 4 (COUNT(*))
HackerRank-Japanese Cities' Attributes, Japanese Cities' Names, Weather Observation Station 1, Weather Observation Station 3, Weather Observation Station 4 (COUNT(*))
2022.08.28 -
HackerRank - Revising the Select Query I, Revising the Select Query II, Select All, Select By ID
HackerRank - Revising the Select Query I, Revising the Select Query II, Select All, Select By ID
2022.08.23