코딩 연습/SQL

[Hacker Rank] Weather Observation Station 19

썬2 2021. 4. 5. 08:02

문제 해설

select round(sqrt(pow(A.a - A.b, 2) + pow(A.c - A.d, 2)), 4)
from (select min(lat_n) as a,
       max(lat_n) as b,
       min(long_w) as c,
       max(long_w) as d
from station) as A;

 

포인트

1. 각 값들을 from절의 서브쿼리로 고른다.

2. sqrt함수(루트 씌운 값), pow함수(제곱근)를 이용한다.

sqrt(4) 2

pow(2, 4) → 16

 

느낀점

sqrt함수와 pow함수를 실제로 다뤄보아서 신기했다.