본문 바로가기

IT Data 분석

[SQL] HackerRank Weather Observation Station 18

728x90

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:


P1(a,b) 고려하다 그리고 P2(c,d) 2D 평면 의 두 점이 됩니다 .

  • a 북위 도 ( STATION 의 LAT_N ) 의 최소값과 같습니다 .
  • b 서부 경도 ( STATION 의 LONG_W ) 의 최소값과 동일합니다 .
  • c 북위 도 ( STATION 의 LAT_N ) 의 최대값과 같습니다 .
  • d 서부 경도 ( STATION 의 LONG_W ) 의 최대값과 같습니다 .

점 사이 의 맨해튼 거리 쿼리 P1 그리고 P2의 규모로 반올림합니다.4 소수 자릿수.

입력 형식

STATION 테이블은 다음과 같이 설명됩니다 .

여기서 LAT_N 은 북쪽 위도이고 LONG_W 는 서쪽 경도입니다.

 


맨해튼 거리 : |x1 - x2| + |y1 - y2| 식으로 두 점 사이의 거리를 재는 방법 

문제요구사항 : P1, P2 사이의 거리를 구해라. (하나의 값을 출력하는 것) 

P1, P2의 위치가 a,b,c,d로 주어진 것이고, 각각을 max(lat_n), min(lat_n), max(long_w), min(long_4)로 구한 것

SELECT ROUND((MAX(LAT_N)-MIN(LAT_N)) + (MAX(LONG_W)-MIN(LONG_W)),4)
FROM STATION