728x90
Weather Observation Station 3 | HackerRank
Query a list of unique CITY names with even ID numbers.
www.hackerrank.com
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
The STATION table is described as follows:
-> STATION 테이블에서 CITY를 선택하면 된다. 조건은 ID number가 짝수이고 중복은 제거한다.
SELECT DISTINCT CITY FROM STATION WHERE IF(ID % 2 = 0, TRUE, FALSE);
1. 중복제거 DISTINCT 키워드 사용
2. where에서 if 조건문 사용 : IF(조건, 참, 거짓)
728x90
'문제 풀이 > Hackerrank SQL' 카테고리의 다른 글
[Hackerrank SQL] Average Population of Each Continent (0) | 2021.02.24 |
---|---|
[Hackerrank SQL] Type of Triangle (0) | 2021.02.24 |
[Hackerrank SQL] Weather Observation Station 13 (0) | 2021.02.23 |
[Hackerrank SQL] Weather Observation Station 8 (0) | 2021.02.23 |
[Hackerrank SQL] Weather Observation Station 5 (0) | 2021.02.23 |