Analysis & Visualization/SQL

[SQL] HackerRank - Weather Observation Station 3

statsbymin 2022. 7. 24. 21:48

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.

 

 

문제요약

더보기

STATION 테이블에서 ID가 짝수(even)인 CITY를 중복 제거하여 추출

풀이

select distinct city 
from station
where id % 2 = 0;
더보기
  • DISTINCT문을 사용해 중복없이 출력
  • 짝수를 출력하기 위해 ID를 2로 나누었을 때 0 인 조건을 추가 

 

결과

출처 

https://www.hackerrank.com/

 

HackerRank

HackerRank is the market-leading technical assessment and remote interview solution for hiring developers. Learn how to hire technical talent from anywhere!

www.hackerrank.com