[HackerRank] Weather Observation Station 19

mzzzi·2022년 4월 25일
0

HackerRank SQL

목록 보기
41/52
post-thumbnail

MySQL > Weather Observation Station 19


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 P1 points P2and and format your answer to display 4 decimal digits.

Input Format
The STATION table is described as follows:

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

My Answer


 /*
a MIN(LAT_N)
b MAX(LAT_N)
c MIN(LONG_W)
d MAX(LONG_W)

p1(a,c) p2(b,d)

sqrt(pow((b-a)) + pow((d-c))) */

SELECT ROUND(SQRT(POW(MAX(LAT_N)-MIN(LAT_N),2) + POW(MAX(LONG_W)-MIN(LONG_W),2)),4)
FROM STATION ;
profile
무럭무럭 성장하라🌳

0개의 댓글