Weather Observation Station 19

hyeh·2022년 8월 17일
0

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


(a,b)는 lat_n의 최소값과 최대값이며 (c,d)는 long_w의 최소값과 최대값이다. 유클리드 거리 P1, P2를 자릿수 4까지 표시하라는 문제다.

💡

  • 유클리디안 거리 : 두 점 사이의 거리를 구하는 법으로 각 축의 값을 뺀 후 제곱한 다음 더해서 루트를 씌운 값이다. 제곱근((x2-x1)^+(y2-y1)^)
  • 문제 자체에 truncate 하라는 말이 없으면 보통 ROUND() 함수를 사용하면 된다.
-- 먼저 필요한 함수와 값을 적어둔다
-- SQRT(), POWER( ,2), ROUND( ,4)
-- a MIN(lat_n)
-- b MAX(lat_n)
-- c MIN(long_w)
-- d MAX(long_w)

SELECT ROUND(SQRT(POWER(MAX(lat_n)-MIN(lat_n), 2) + POW(MAX(long_w)-MIN(long_w), 2)), 4)
FROM station

💡💡

  • 제곱근 함수 : SQRT()
  • 제곱 함수 : POWER( ,2)
  • 반올림 함수 : ROUND( ,4)
profile
좌충우돌 천방지축 룰루랄라 데이터 공부

0개의 댓글