SQL/HACKER_RANK
[MEDIUM] Weather Observation Station 18
소금깨
2022. 10. 13. 22:03
Weather Observation Station 18 | HackerRank
Query the Manhattan Distance between two points, round or truncate to 4 decimal digits.
www.hackerrank.com
문제 조건
Consider P1(a,b) and P2(c,d) to be two points on a 2D plane.
- happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
- happens to equal the minimum value in Western Longitude (LONG_W in STATION).
- happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
- happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points and and round it to a scale of decimal places.
Input Format
The STATION table is described as follows:

문제 풀이
두 점을 명시를 해줬기 때문에 max(lat_n)-min(lat_n) + max(long_w)-min(long_w)로 간단하게 풀 수 있었음
select round((max(lat_n)-min(lat_n)) + (max(long_w)-min(long_w)),4)
from station