728x90
반응형
https://www.hackerrank.com/challenges/weather-observation-station-19/problem?isFullScreen=true
Weather Observation Station 19 | HackerRank
Query the Euclidean Distance between two points and round to 4 decimal digits.
www.hackerrank.com
문제
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:
![](https://blog.kakaocdn.net/dn/MvT9E/btssarRZmGK/Tjm2bIDtkQAwUNORHWAep1/img.jpg)
where LAT_N is the northern latitude and LONG_W is the western longitude.
Code
SELECT ROUND(SQRT(POW(MAX(LAT_N) - MIN(LAT_N), 2) + POW(MAX(LONG_W) - MIN(LONG_W), 2)),4)
FROM STATION
728x90
반응형
'SQL > MySQL' 카테고리의 다른 글
[MySQL/HackerRank] Draw The Triangle 2 (0) | 2023.08.29 |
---|---|
[MySQL/HackerRank] Draw The Triangle 1 (0) | 2023.08.29 |
[MySQL/HackerRank] Weather Observation Station 18 (0) | 2023.08.25 |
[MySQL/HackerRank] Weather Observation Station 17 (0) | 2023.08.25 |
[MySQL/HackerRank] Weather Observation Station 16 (0) | 2023.08.25 |