| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- SQLite
- having
- airflow.cfg
- 프로그래머스
- 파이썬
- join
- 결측값
- hackerrank
- Limit
- not in
- SUM
- solvesql
- MySQL
- TRUNCATE
- SQL
- 전처리
- 데이터시각화
- GROUPBY
- Oracle
- airflow 설치
- seaborn
- 데이터분석
- 데이터리안 웨비나
- 머신러닝
- 그로스해킹
- 다중 JOIN
- Round
- pandas
- PostgreSQL
- matplotlib
Archives
- Today
- Total
Milky's note
[HackerRank](E) Weather Observation Station 6 본문
https://www.hackerrank.com/challenges/weather-observation-station-6/problem?isFullScreen=true
Weather Observation Station 6 | HackerRank
Query a list of CITY names beginning with vowels (a, e, i, o, u).
www.hackerrank.com
[문제]
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.
[답]
- mysql
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 LEFT(CITY,1) IN ('a','e','i','o','u');
a, e, i, o, u로 시작하는 도시 이름을 중복없이 조회하는 문제이다.
다중 like 쿼리를 사용하거나,
자리 조회하는 left, right 함수에 in 을 사용하여 조회하는 방법도 가능하다.
like in 이 되면 좋겠지만 이 문법이 안되기 때문에 위의 두 가지 방법을 사용해서 문제를 해결하였다.
'SQL > SQL 코딩 테스트-HackerRank' 카테고리의 다른 글
| [HackerRank](E) Weather Observation Station 8 (0) | 2022.03.16 |
|---|---|
| [HackerRank](E) Weather Observation Station 7 (0) | 2022.03.16 |
| [HackerRank](E) Weather Observation Station 5 (0) | 2022.03.16 |
| [HackerRank](E) Weather Observation Station 4 (0) | 2022.03.16 |
| [HackerRank](E) Weather Observation Station 3 (0) | 2022.03.16 |
Comments