[HackerRank] Basic SELECT S3

Ga0·2023년 8월 13일
0

HackerRank

목록 보기
3/5

문제1

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.
(첫 시작은 대문자, 끝은 소문자로 되어있다.)

-- 1
SELECT CITY
 FROM STATION
 WHERE REGEXP_LIKE(CITY, '^A|^E|^I|^O|^U')
   AND REGEXP_LIKE(CITY, 'a$|e$|i$|o$|u$')
 GROUP BY CITY;
 
 -- 2
 SELECT CITY
 FROM STATION
 WHERE REGEXP_LIKE(CITY, '^[A|E|I|O|U]')
   AND REGEXP_LIKE(CITY, '[a|e|i|o|u]$')
 GROUP BY CITY;

문제2

Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.

SELECT CITY 
 FROM STATION 
 WHERE NOT REGEXP_LIKE(CITY, '^[A|E|I|O|U]')
 GROUP BY CITY;  

문제3

Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates.

SELECT CITY 
 FROM STATION 
 WHERE NOT REGEXP_LIKE(CITY, '[a|e|i|o|u]$')
 GROUP BY CITY;  

문제4

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.

 SELECT CITY
 FROM STATION
 WHERE NOT REGEXP_LIKE(CITY, '^[A|E|I|O|U]')
   OR NOT REGEXP_LIKE(CITY, '[a|e|i|o|u]$')
 GROUP BY CITY;

문제5

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.

 SELECT CITY
 FROM STATION
 WHERE NOT REGEXP_LIKE(CITY, '^[A|E|I|O|U]')
   AND NOT REGEXP_LIKE(CITY, '[a|e|i|o|u]$')
 GROUP BY CITY;

0개의 댓글