Please see github.com/anusha-murali for all of my repositories.
Consider $P_1(a, c)$ and $P_2(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 $P_1$ and $P_2$ and format your answer to display 4 decimal digits.
The STATION table is described as follows:
where LAT_N
is the northern latitude and LONG_W
is the western longitude.
We first find $a, b, c,$ and $d$ by selecting MIN(LAT_N)
, MAX(LAT_N)
, MIN(LONG_W)
, and MAX(LONG_W)
from STATION
in an inline view (aliased IV
),
and then use these quantities in the outer query to compute the Euclidean distance as follows:
SELECT ROUND(SQRT((b-a)*(b-a) + (d-c)*(d-c)), 4)
FROM
(SELECT MIN(LAT_N) a, MAX(LAT_N) b, MIN(LONG_W) c, MAX(LONG_W) d FROM STATION) IV;