> For the complete documentation index, see [llms.txt](https://xinruiqian227.gitbook.io/learning-by-doing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xinruiqian227.gitbook.io/learning-by-doing/sql/sql/hackerrank/medium/untitled.md).

# Weather Observation Station 19

Consider P1() 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](https://en.wikipedia.org/wiki/Euclidean_distance) between points  and  and *format your answer* to display  decimal digits.

**Input Format**

The **STATION** table is described as follows:

![](https://s3.amazonaws.com/hr-challenge-images/9336/1449345840-5f0a551030-Station.jpg)

where *LAT\_N* is the northern latitude and *LONG\_W* is the western longitude.

### Analysis

we will need four values from the station table: max lat\_n, min latitude, max longitude, min longitude.\
The Euclidean Distance is

![{\displaystyle d(p,q)={\sqrt {(p\_{1}-q\_{1})^{2}+(p\_{2}-q\_{2})^{2}}}.}](https://wikimedia.org/api/rest_v1/media/math/render/svg/9c0157084fd89f5f3d462efeedc47d3d7aa0b773)

&#x20;\==>sqrt ( (a - b)^2 + (c - d)^2)).

* The distance can be converted into ==> SQRT(POW(MAX(LAT\_N)-MIN(LAT\_N),2)+POW(MAX(LONG\_W)-MIN(LONG\_W),2))
* &#x20;round it to 4 decimal places ==> ROUND(SQRT(POW(MAX(LAT\_N)-MIN(LAT\_N),2)+POW(MAX(LONG\_W)-MIN(LONG\_W),2)),4)
* from station table ==> FROM STATION

### Query

```sql
SELECT ROUND(SQRT(POW(MAX(LAT_N)-MIN(LAT_N),2)+POW(MAX(LONG_W)-MIN(LONG_W),2)),4) FROM STATION
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xinruiqian227.gitbook.io/learning-by-doing/sql/sql/hackerrank/medium/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
