HackerRank/SQL

[hackerrank] Weather Observation Station 19

예쁜꽃이피었으면 2022. 9. 6. 16:30

[hackerrank] Prepare > SQL > Aggregation > Weather Observation Station 19

 

[문제]

 

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

Query the Euclidean Distance between points  and  and format your answer to display  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.

[MYSQL]

 

 

[ORCALE]

모르겠어서 그냥 검색했다.

select
    round(sqrt(power(max(LAT_N) - min(LAT_N),2) + 
                power(max(LONG_W) - min(LONG_W),2)),4)
from station

 

 

 

 


https://en.wikipedia.org/wiki/Euclidean_distance

 

Euclidean distance - Wikipedia

Length of a line segment Using the Pythagorean theorem to compute two-dimensional Euclidean distance In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points. It can be calculated f

en.wikipedia.org

제곱 구하기 POWER(n1 , n2)

-  첫번째 인자값이 음수인 경우 실수를 제공할 수 없다.

제곤급 구하기  sqrt(대상 숫자)

- 양의 자리 실수만 가능

반응형