HackerRank/SQL

[hackerrank] Weather Observation Station 18

예쁜꽃이피었으면 2022. 9. 6. 16:10

[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()

 

 

 

 

 

 

 

반응형