Weather Observation Station 18 SQL Hacker Rank Solution

Hello coders, In this post, you will learn how to solve the Weather Observation Station 18 SQL Hacker Rank Solution. This problem is a part of the SQL Hacker Rank series.

Weather Observation Station 18 SQL Hacker Rank Solution
Weather Observation Station 18 SQL Hacker Rank Solution

Weather Observation Station 18 SQL Hacker Rank Solution

Problem

Consider  and  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  and  and round it to a scale of  decimal places.

Input Format

The STATION table is described as follows:

Weather Observation Station 18 SQL Hacker Rank Solution

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

Weather Observation Station 18 SQL Hacker Rank Solution

SELECT ROUND(ABS(MIN(LAT_N)-MAX(LAT_N)) +
                                ABS(MIN(LONG_W)-MAX(LONG_W)), 4) FROM STATION;

Disclaimer: The above Problem (Weather Observation Station 18) generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes.

Sharing Is Caring