문제 해설
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함수를 실제로 다뤄보아서 신기했다.
'코딩 연습 > SQL' 카테고리의 다른 글
우유와 요거트가 담긴 장바구니 (0) | 2021.07.05 |
---|---|
[Hacker Rank] Weather Observation Station 20 (0) | 2021.04.05 |
[Hacker Rank] Weather Observation Station 18 (0) | 2021.04.05 |
[Hacker Rank] Aggregation2 (0) | 2021.04.05 |
[Hacker Rank] Revising Aggregations1 (0) | 2021.04.04 |