Weather Observation Station 3
Problem
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:
(ID 번호가 짝수인 도시에 대해 STATION에서 CITY 이름의 목록을 작성하시오. 결과를 아무 순서로나 출력하되, 답변에서 중복을 제외하시오.)
Solution(Oracle)
SELECT DISTINCT CITY FROM STATION
WHERE MOD(ID, 2) = 0;
MOD 함수 - 숫자를 나눈 나머지 값 구함
MOD([나눗셈 될 숫자(필수)], [나눌 숫자(필수)])
DISTINCT - 중복 데이터 제거
SELECT DISTINCT DEPTNO FROM EMP;
https://www.hackerrank.com/challenges/weather-observation-station-3/problem
Weather Observation Station 3 | HackerRank
Query a list of unique CITY names with even ID numbers.
www.hackerrank.com
'SQL' 카테고리의 다른 글
[HackerRank SQL] Weather Observation Station 7 (Oracle) (0) | 2024.03.31 |
---|---|
[HackerRank SQL] Weather Observation Station 6 (Oracle) (0) | 2024.03.30 |
[HackerRank SQL] Weather Observation Station 5 (Oracle) (0) | 2024.03.29 |
[HackerRank SQL] Weather Observation Station 4 (Oracle) (0) | 2024.03.28 |
[HackerRank SQL] Weather Observation Station 1 (Oracle) (0) | 2024.03.26 |