반응형

해결 방법 : 문제에 주어진 조건대로 함수를 사용하고, 단위만 맞춰주면 된다.

- 애초에 실수값이기 때문에 CONVERT 대신 ROUND(<원본 숫자>, 소수점)를 사용해도 된다.

 

www.hackerrank.com/challenges/weather-observation-station-18/problem

 

Weather Observation Station 18 | HackerRank

Query the Manhattan Distance between two points, round or truncate to 4 decimal digits.

www.hackerrank.com

SELECT convert(max(lat_n) - min(lat_n) + max(long_w) - min(long_w), decimal(65,4))
FROM station

 

 

www.hackerrank.com/challenges/weather-observation-station-19/problem

 

Weather Observation Station 19 | HackerRank

Query the Euclidean Distance between two points and round to 4 decimal digits.

www.hackerrank.com

SELECT convert(sqrt(power(max(lat_n) - min(lat_n), 2) + power(max(long_w) - min(long_w), 2)), decimal(65,4))
FROM station

 

반응형

'IT study > SQL' 카테고리의 다른 글

The Report (IF)  (0) 2021.04.26
Weather Observation Station 20  (0) 2021.04.25
New Companies (+ 형 변환)  (0) 2021.04.22
Binary Tree Nodes  (0) 2021.04.18
Occupations (SET, CASE)  (0) 2021.04.17

+ Recent posts