Sunday, 24 March 2019

Weather Observation Station 19 HackerRank SQL Solution in MYSQL

Problem:-

Consider  and  to be two points on a 2D plane where  are the respective minimum and maximum values of Northern Latitude (LAT_N) and  are the respective minimum and maximum values of Western Longitude (LONG_W) in STATION.
Query the Euclidean Distance between points  and  and format your answer to display  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;

No comments:

Post a Comment

Error While embed the video in Your website page

Error:- Refused to display '<URL>' in a frame because it set 'X-Frame-Options' to 'sameorigin Solution:- if ...