HackerRank[MySQL] : Weather Observation Station 11

sooyeon·2022년 7월 3일
0

HackerRank SQL

목록 보기
16/22

Q

SELECT DISTINCT CITY
FROM STATION 
WHERE CITY REGEXP '^[^aeiou]' OR 
      CITY REGEXP '[^aeiou]$'


REGEXP'[]|[]'

# '|' Represents the OR operator
SELECT DISTINCT CITY FROM STATION
WHERE CITY REGEXP '^[^aeiou]|[^aeiou]$';

RLIKE

# '.*' matches everything between two expressions.
SELECT DISTINCT CITY 
FROM STATION 
WHERE CITY RLIKE "^[^aieou]|.*[^aeiou]$" 

REGEXP_LIKE

SELECT DISTINCT CITY FROM STATION
WHERE REGEXP_LIKE(CITY, '^[^AEIOU]|[^aeiou]$');
# WHERE REGEXP_LIKE(CITY, '^[^aeiou].*[^aeiou]$','i') ;

NOT IN

SELECT DISTINCT CITY 
FROM STATION
WHERE CITY NOT IN (SELECT DISTINCT CITY 
			FROM STATION 
            WHERE REGEXP_LIKE(CITY, '^[aeiou].*[aeiou]$','i')) ;

SUBSTR

SELECT DISTINCT CITY
FROM STATION 
WHERE SUBSTRING(CITY,1,1) NOT IN ('A','E','I','O','U') OR 
SUBSTRING(CITY,-1,1) NOT IN ('A','E','I','O','U');

0개의 댓글