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
'SQL > hacker rank' 카테고리의 다른 글
[Easy] Weather Observation Station 3 (0) | 2022.10.24 |
---|---|
[EASY] Weather Observation Station 1 (0) | 2022.10.24 |
[MEDIUN] New Companies (0) | 2022.10.13 |
[EASY] Japanese Cities' Names (0) | 2022.10.13 |
[EASY] Japanese Cities' Attributes (0) | 2022.10.13 |