Weather Observation Station 19 in SQL | HackerRank Solution

Hello coders, today we are going to solve Weather Observation Station 19 HackerRank Solution in SQL.

Weather Observation Station 19

Contents

Problem

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:

FieldType
IDNUMBER
CITYVARCHAR2(21)
STATEVARCHAR2(2)
LAT_NNUMBER
Long_WNUMBER
STATION

where LAT_N is the northern latitude and LONG_W is the western longitude.

Solution – Weather Observation Station 19 in SQL

MySQL

SELECT ROUND(SQRT(POWER(MAX(LAT_N)-MIN(LAT_N),2)+POWER(MAX(LONG_W)-MIN(LONG_W),2)),4)
FROM STATION;

Disclaimer: The above Problem (Weather Observation Station 19) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

Your email address will not be published.