[HackerRank] Weather Observation Station 18

mzzzi·2022년 4월 25일
0

HackerRank SQL

목록 보기
40/52
post-thumbnail

MySQL > Weather Observation Station 18


Consider P1(a, b) and P2(a, b) 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 P1 points and P2 and round it to a scale of 4 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.


My Answer


SELECT ROUND(ABS(MIN(LAT_N)-MAX(LAT_N)) + ABS(MIN(LONG_W)-MAX(LONG_W)),4)
FROM STATION ;
profile
무럭무럭 성장하라🌳

0개의 댓글