[코드카타] SQL 70 Weather Observation Station 18

Data_Student·2024년 12월 16일
0

코드카타

목록 보기
80/82

[코드카타] SQL 70 Weather Observation Station 18

70. Weather Observation Station 18
https://www.hackerrank.com/challenges/weather-observation-station-18/problem?isFullScreen=true

Consider P1(a,b) and P2(c,d) to be two points on a 2D plane.
a happens to equal the minimum value in Northern Latitude (LAT_N in STATION).
b happens to equal the minimum value in Western Longitude (LONG_W in STATION).
c happens to equal the maximum value in Northern Latitude (LAT_N in STATION).
d happens to equal the maximum value in Western Longitude (LONG_W in STATION).
Query the Manhattan Distance between points P1 and P2 and round it 
to a scale of 4 decimal places.
select round(abs(min(lat_n)-max(lat_n))+abs(min(long_w)-max(long_w)),4)
from station
맨하튼 거리 공식을 활용한 문제 해결
맨하튼 공식 : |x1-x2| + |y1-y2|
쿼리문으로 작성할 때 필요한 함수 : abs() - 절대값을 구하는 함수

0개의 댓글