[HackerRank MySQL] Weather Observation Station 19 - POWER & SQRT (SQL에서 제곱과 제곱근 계산하기)
2021. 2. 15. 22:58ㆍToday I Learned.../MySQL
Weather Observation Station 19
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:
where LAT_N is the northern latitude and LONG_W is the western longitude.
Solution
select round(sqrt(power(max(lat_n)-min(lat_n), 2)+power(max(long_w)-min(long_w), 2)), 4)
from station
POWER & SQRT in SQL (SQL에서 제곱과 제곱근 계산하기)
Syntax | Example | |
Power / Involution (거듭제곱) | POWER(base, exponent) | POWER(2, 3) → 8 |
Square Root (제곱근) | SQRT(numeric value) | SQRT(25) → 5 |
Reference: HackerRank Practice > SQL > Aggregation > Weather Observation Station 19
'Today I Learned... > MySQL' 카테고리의 다른 글
[HackerRank MySQL] Binary Tree Nodes (0) | 2021.02.22 |
---|---|
[HackerRank MySQL] Placements (0) | 2021.02.22 |
[HackerRank MySQL] Top Competitors (0) | 2021.02.15 |
[HackerRank MySQL] New Companies (0) | 2021.02.10 |
[HackerRank MySQL] Weather Observation Station 18 (0) | 2021.02.10 |