일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- CASE
- HackerRank
- 서브쿼리
- MySQL
- nlp논문
- Statistics
- 자연어처리
- airflow
- 설명의무
- 코딩테스트
- 논문리뷰
- torch
- SQL 날짜 데이터
- t분포
- GRU
- NLP
- sql
- 자연어 논문
- sigmoid
- 짝수
- inner join
- 카이제곱분포
- 그룹바이
- Window Function
- LSTM
- SQL코테
- 자연어 논문 리뷰
- leetcode
- update
- 표준편차
- Today
- Total
HAZEL
[SQL : 정규표현식 ] HackerRank : Weather Observation Station 6 / 9 본문
[SQL : 정규표현식 ] HackerRank : Weather Observation Station 6 / 9
Rmsid01 2021. 5. 15. 16:59Weather Observation Station 6
>> 문제
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].*'
' . ' : 어떤문자임에도 다 매치를 시켜준다는 의미
' ^ ' : Beginning Match . ^ 를 입력하면, 맨 앞글자가 왔을 때에만 매치를 시켜준다.
SQL 에서는 대소문자에 대해서 예민하지 않기 때문에 , abcd 와 ABCD 가 같은 의미를 가진다.
https://www.hackerrank.com/challenges/weather-observation-station-6/problem?h_r=internal-search
Weather Observation Station 9
>> 문제
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 city NOT REGEXP '^[aeiou].*'
: NOT 만 붙이면 간단하게, 원하는 것의 반대를 수행할 수 있다.
* 정규표현식을 공부하기 위한 홈페이지
https://regexone.com/lesson/letters_and_digits