일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 |
30 | 31 |
- update
- HackerRank
- leetcode
- CASE
- SQL코테
- 서브쿼리
- t분포
- 표준편차
- 자연어처리
- airflow
- NLP
- Statistics
- 자연어 논문 리뷰
- 코딩테스트
- inner join
- 짝수
- sql
- 자연어 논문
- SQL 날짜 데이터
- 그룹바이
- GRU
- 카이제곱분포
- sigmoid
- nlp논문
- Window Function
- MySQL
- 논문리뷰
- 설명의무
- LSTM
- torch
- 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 6 | HackerRank
Query a list of CITY names beginning with vowels (a, e, i, o, u).
www.hackerrank.com
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
RegexOne - Learn Regular Expressions - Lesson 1½: The 123s
Characters include normal letters, but digits as well. In fact, numbers 0-9 are also just characters and if you look at an ASCII table, they are listed sequentially. Over the various lessons, you will be introduced to a number of special metacharacters use
regexone.com
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).
regexr.com