반응형
츄르사려고 코딩하는집사입니다.
1. [HackerRank] Weather Observation Station 6 SQL
2. 문제 출처
https://www.hackerrank.com/challenges/weather-observation-station-6/problem
3. 문제
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.
4. 풀이
- LENGTH() 함수를 통해 길이를 구하고, CITY의 길이로 각 오름차순과 내림차순을 한 다음에, CITY의 알파벳 순서로 오름차순을 하고 1개만 출력한다.
5. 소스 코드
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 REGEXP_LIKE(CITY, '^A|^E|^I|^O|^U');
- DISTINCT는 중복을 제거해 준다.
반응형
'알고리즘 > HackerRank' 카테고리의 다른 글
[HackerRank] Weather Observation Station 10 오라클(Oracle) (0) | 2021.09.08 |
---|---|
[HackerRank] Weather Observation Station 9 오라클(Oracle) (0) | 2021.09.08 |
[HackerRank] Weather Observation Station 8 오라클(Oracle) (0) | 2021.09.08 |
[HackerRank] Weather Observation Station 7 오라클(Oracle) (0) | 2021.09.07 |
[HackerRank] Weather Observation Station 5 SQL (0) | 2021.09.07 |
[HackerRank] Weather Observation Station 4 SQL (0) | 2021.09.06 |
[HackerRank] Weather Observation Station 3 SQL (0) | 2021.09.06 |
[HackerRank] Weather Observation Station 1 SQL (0) | 2021.09.06 |
최근댓글