728x90
아니 저번 글에 바로
^을 두 번 쓰면 not 기능이 있다고 썼는데
10을 풀면서 아.. 대괄호 안에 ^을 쓰면 not 기능이 있다는 걸 깨달음
https://www.hackerrank.com/challenges/weather-observation-station-10/problem?isFullScreen=true
Weather Observation Station 10 | HackerRank
Query a list of CITY names not ending in vowels.
www.hackerrank.com
내 처음 답변(오답)
SELECT DISTINCT CITY
FROM STATION
WHERE CITY REGEXP '[aeiou$]$'
내 생각)
앞에 오는 게 ^로 표현됐으니까
마지막 글자 아닌 걸 표현하려면 $겠지?
그럼 $을 대괄호 안밖 둘 다 써야겠지?
아님
다음 내 답변(정답)
select distinct city
from station
where city not regexp '[aeiou]$'
결국 not regexp 써서 밖에만 $ 붙임
다른 사람 정답 답변
select distinct CITY from STATION where CITY RLIKE '[^aeiou]$'
대괄호 안에 ^ 쓰면 not 기능을 하는군아..
새로 알았다
728x90
'SQL' 카테고리의 다른 글
[해커랭크] Higher Than 75 Marks (0) | 2023.07.11 |
---|---|
[해커랭크] Weather Observation Station 11&12 (0) | 2023.07.11 |
[해커랭크] Weather Observation Station 9(^의 발견) (0) | 2023.07.08 |
[해커랭크] Weather Observation Station 8(REGEXP, RLIKE의 발견) (0) | 2023.07.08 |
[리트코드] Mysql - Rising Temperature (0) | 2022.11.16 |