Milky's note

[HackerRank](E) Weather Observation Station 3 본문

SQL/SQL 코딩 테스트-HackerRank

[HackerRank](E) Weather Observation Station 3

밀뿌 2022. 3. 16. 14:34

https://www.hackerrank.com/challenges/weather-observation-station-3/problem?isFullScreen=true 

 

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:

where LAT_N is the northern latitude and LONG_W is the western longitude.

 

[답]

-oracle

select distinct(city) from station
where mod(id,2)=0;

 

mod는 나누고 난 뒤 나머지값을 의미하는 함수

# 2로 나눈 값의 나머지가 1이므로 홀수
mod(컬럼,2) = 1

# 2로 나눈 값의 나머지가 0이므로 짝수
mod(컬럼,2) = 0
Comments