# Weather Observation Station 18 in SQL | HackerRank Solution

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

## Problem

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  decimal places.

## Input Format

The STATION table is described as follows:

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

## Solution – Weather Observation Station 18 in SQL

### MySQL

```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) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

### 3 thoughts on “Weather Observation Station 18 in SQL | HackerRank Solution”

1. select round(abs(max(lat_n) – min(lat_n) + abs((max(long_w)) – min(long_w))),4) from station;

it should like this.

2. modified query:
select cast(round(abs(min(lat_n) – max(lat_n)) + abs(min(long_w) – max(long_w)),4) as decimal(10, 4)) from station;

3. Subhrashil Roy

select round(((max(LAT_N)+max(LONG_W)-min(LAT_N)-min(LONG_W)),4) from STATION
whats wrong here