SQL
카타
<문제 141. Weather Observavtion Station 8 : 정규표현식>
select distinct city
from station
where city regexp '^[aeiou].*[aeiou]$'
<문제 142. Weather Observavtion Station 9 : 정규표현식>
select distinct city
from station
where city not regexp '^[aeiou]'
<문제 143. Weather Observavtion Station 10 : 정규표현식>
select distinct city
from station
where city not regexp '[aeiou]$'
<문제 144. Weather Observavtion Station 11 : 정규표현식>
정답
select distinct city
from station
where city not regexp '^[aeiou]' and city not regexp '[aeiou]$'
*주의
select distinct city
from station
where city not regexp '^[aeiou].*[aeiou]$'
오답 이유 :
모음으로 시작하지 않으면서 동시에 끝나지 않는, 즉 두 가지 조건 모두를 충족하는 것만 필터링됨
=>시작만 모음이거나, 끝만 모음인 경우는 필터링X
*정규표현식 관련 참고
[SQL] Oracle sql : 2. 정규표현식 - (2) 패턴매칭
메타문자1 : . + ? * ▶ 예시: 1) ... 2) .ab+ 3) 1a?b 4) 1a*b 메타문자2: [ ] , [^ ] , ( ) ▶ 예시: 1) ...
blog.naver.com
'TIL 통합 > SQL' 카테고리의 다른 글
REGEXP (0) | 2024.02.27 |
---|---|
서울시 (청년) 인구 데이터 가공 - 서브쿼리, JOIN, 숫자인식 (0) | 2024.02.08 |
UNION, 정규표현식 (0) | 2024.02.01 |
정규 표현식 (0) | 2024.01.31 |
INTERSECT, GROUP_CONCAT, 집계함수 (0) | 2024.01.30 |