본문 바로가기

Language/SQL

[HackerRank][SQL][Aggregation] Weather Observation Station 19 - 컴도리돌이

728x90
 

Weather Observation Station 19 | HackerRank

Query the Euclidean Distance between two points and round to 4 decimal digits.

www.hackerrank.com


Problem

Consider  P1(a,b) and P2(c,d) to be two points on a 2D plane where (a,b)  are the respective minimum and maximum values of Northern Latitude (LAT_N) and (c,d)  are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.

Query the Euclidean Distance between points P1 and P2  and format your answer to display

4 decimal digits.

-> 다음을 소수점 4자리까지 출력하시오. (truncate)

점 p1과 점 p2의 유클리드 호제법 거리를 구하시오.

 

*유클리드 호제법의 제곱 + 제곱 의 루트를 power 함수만 사용해서 표현을 하였다.


Answer

select truncate(power(power(max(lat_n) - min(lat_n),2) + power(max(long_w) - min(long_w),2),0.5),4)
from station