Weather Observation Station 18
Consider P1(a,b) and P2(c,d) to be two points on a 2D plane.
a happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
b happens to equal the minimum value in Western Longitude (LONG_W in STATION).
c happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
d happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points P1 and P2 and round it to a scale of 4 decimal places.
두 점 P1, P2 사이의 맨하탄 거리를 소수 4번째점까지 반올림해서 구하라는 문제였다.
SELECT ROUND(ABS(MIN(lat_n) - MAX(lat_n)) +
ABS(MIN(long_w) - MAX(long_w)), 4)
FROM station;
💡
|x1-x2| + |y1-y2|
로 구할 수 있으므로, 이 식을 적용해 |a-c| + |b-d|
로 구할 수 있다.ABS()
함수로 구할 수 있다!