HAZEL

[SQL : HackerRank] Weather Observation Station 3 / Weather Observation Station 19 본문

DATA ANALYSIS/SQL

[SQL : HackerRank] Weather Observation Station 3 / Weather Observation Station 19

Rmsid01 2021. 3. 1. 12:46

1] Weather Observation Station 3


>> 문제

Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
The STATION table is described as follows:

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

 

>> 문제 푼 코드

SELECT distinct city
FROM STATION
WHERE id  % 2 = 0

 

www.hackerrank.com/challenges/weather-observation-station-3/problem

 

Weather Observation Station 3 | HackerRank

Query a list of unique CITY names with even ID numbers.

www.hackerrank.com

 

 

2] Weather Observation Station 19


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:

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

 

>> 문제 푼코드

SELECT  round(SQRT(POWER(min(lat_n) - max(lat_n),2) +
            POWER(min(long_w)- max(long_w),2)),4)
from station

 

www.hackerrank.com/challenges/weather-observation-station-19/problem

 

Weather Observation Station 19 | HackerRank

Query the Euclidean Distance between two points and round to 4 decimal digits.

www.hackerrank.com