[hackerrank] Prepare > SQL > Aggregation > Weather Observation Station 18
[문제]
Consider and 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:
where LAT_N is the northern latitude and LONG_W is the western longitude.
[MYSQL]
[ORCALE]
select round(abs(min(lat_n) - max(lat_n)) + abs( min(long_w)- max(long_w)),4)
from station;
https://xlinux.nist.gov/dads/HTML/manhattanDistance.html
In a plane with p1 at (x1, y1) and p2 at (x2, y2), it is |x1 - x2| + |y1 - y2|.
오라클 절대값 함수 abs()
반응형
'HackerRank > SQL' 카테고리의 다른 글
[hackerrank] Population Census (0) | 2022.09.06 |
---|---|
[hackerrank] Weather Observation Station 19 (0) | 2022.09.06 |
[hackerrank] Weather Observation Station 17 (0) | 2022.09.06 |
[hackerrank] Weather Observation Station 16 (0) | 2022.09.06 |
[hackerrank] Weather Observation Station 15 (0) | 2022.08.31 |