해커랭크 Weather Observation Station 17 문제 바로가기 

 

 

문제 해석

Query the Western Longitude(LONG_W)where the smallest Northern Latitude(LAT_N) in STATION is greater than 38.7780.
station 테이블에서 북위(LAT_N) 38.7780보다 큰 값 중에서 가장 작은 북위일 때, 서부경도의 값을 나타내는 쿼리를 입력

Round your answer to 4 decimal places.
반올림해서 소수점 4자리까지 나타내기.

Input Format

The STATION table is described as follows:

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

 

문제 풀이

SELECT ROUND(LONG_W, 4)
FROM station 
WHERE LAT_N > 38.7780
ORDER BY LAT_N ASC
LIMIT 1

SELECT ROUND(LONG_W, 4) -- LONG_W을 반올림해서 소수점4자리까지 나타냄
FROM station                       
WHERE LAT_N > 38.7780     -- 비교연산자와 WHERE 조건문 사용, 38.7780보다 큰 LAT_N
ORDER BY LAT_N ASC         -- LAT_N을 오름차순 정렬, 조건에 맞는 가장 낮은 값이 맨 위에 나타남
                                         (ASC는 생략 가능)
LIMIT 1                            -- 첫번째 데이터만 보기

+ Recent posts