DATA ANALYSIS/SQL
[서브쿼리] hackerrank : Weather Observation Station 17
Rmsid01
2021. 11. 15. 23:56
>> 문제
Weather Observation Station 17
Query the Western Longitude (LONG_W)where the smallest Northern Latitude (LAT_N) in STATION is greater than 38.7780. Round your answer to decimal places.
-> LONG_W 을 소수점 4자리까지 가져와라.
조건 1, LAT_N이 38.7780 보다 큰 것
조건 2 . 조건 1중에 가장 작은 LAT_N이다.
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 = (
SELECT min(LAT_N)
FROM STATION
WHERE LAT_N > 38.7780
)
>> 두번째 답변 : LIMIT 을 사용해서 풀기
SELECT ROUND(LONG_W, 4)
FROM STATION
WHERE LAT_N > 38.7780
ORDER BY LAT_N
LIMIT 1
https://www.hackerrank.com/challenges/weather-observation-station-17/problem