Prepare > SQL > Aggregation > Weather Observation Station 16
2023. 5. 18. 20:56ㆍHackerRank-My SQL
Weather Observation Station 16 | HackerRank
Query the smallest of STATION's Northern Latitudes that is greater than 38.7780, and round to 4 decimal places
www.hackerrank.com
문제
Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780. Round your answer to 4 decimal places.
코드
SELECT ROUND(MIN(LAT_N), 4) FROM STATION
WHERE LAT_N > 38.7780;
노트
SELECT ROUND(LAT_N, 4) FROM STATION
WHERE LAT_N > 38.7780
ORDER BY LAT_N ASC
LIMIT 0,1;
- 최솟값에 ORDER BY로 접근하기
두 번째 시도
SELECT ROUND(LAT_N, 4) FROM STATION
WHERE LAT_N = (SELECT MIN(LAT_N) FROM STATION WHERE LAT_N > 38.7780;
- 첫 번째가 더 나은듯?
'HackerRank-My SQL' 카테고리의 다른 글
Prepare > SQL > Aggregation > Weather Observation Station 18 (0) | 2023.05.20 |
---|---|
Prepare > SQL > Aggregation > Weather Observation Station 17 (0) | 2023.05.18 |
Prepare > SQL > Aggregation > Weather Observation Station 15 (0) | 2023.05.18 |
Prepare > SQL > Aggregation > Weather Observation Station 14 (0) | 2023.05.18 |
Prepare > SQL > Aggregation > Weather Observation Station 13 (0) | 2023.05.18 |