728x90
❓ Question
https://www.hackerrank.com/challenges/weather-observation-station-15
Weather Observation Station 15 | HackerRank
Query the Western Longitude for the largest Northern Latitude under 137.2345, rounded to 4 decimal places.
www.hackerrank.com

❗ Answer
SELECT ROUND(long_w,4)
FROM station
WHERE lat_n = (SELECT MAX(lat_n)
FROM station
WHERE lat_n < 137.2345);
📌 Discussion
- sub query scalar로 WHERE 절의 조건에 해당하는 lat_n 중 최댓값을 찾는다.
- 이후 main query WHERE 절에서 조건을 걸어주고 ROUND로 반올림하여 추출
'SQL 문제풀이' 카테고리의 다른 글
| [해커랭크 SQL] Aggregation - Weather Observation Station 17 (0) | 2023.08.25 |
|---|---|
| [해커랭크 SQL] Aggregation - Weather Observation Station 16 (0) | 2023.08.25 |
| [해커랭크 SQL] Aggregation - Weather Observation Station 14 (0) | 2023.08.25 |
| [해커랭크 SQL] Aggregation - Weather Observation Station 13 (0) | 2023.08.25 |
| [해커랭크 SQL] Aggregation - Weather Observation Station 2 (0) | 2023.08.25 |