[HackerRank] Weather Observation Station 19(SQRT, POW)

생각하는 마리오네트·2021년 9월 15일
0

SQL

목록 보기
14/39

Consider P1(a,c) and P2(b, 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.


Input Format

The STATION table is described as follows:

FieldType
IDNUMBER
CITYVARCHAR2(21)
STATEVARCHAR2(2)
LAT_NNUMBER
LONG_WNUMBER

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


MY ANSWER

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

TIP. 제곱근과 제곱, 괄호에 주의해서 풀면된다.

profile
문제를해결하는도구로서의"데이터"

0개의 댓글