혜온의 이것저것

[HackerRank] Weather Observation Station 18 (MySQL) 본문

Data Analysis/SQL

[HackerRank] Weather Observation Station 18 (MySQL)

혜온 :) 2022. 8. 22. 10:03

https://www.hackerrank.com/challenges/weather-observation-station-18/problem?isFullScreen=true 

 

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.

  • 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.

Input Format

The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

 

풀이
select round((max(lat_n)-min(lat_n))+(max(long_w)-min(long_w)),4)
from station
Comments