Milky's note

[HackerRank](E) Weather Observation Station 15 본문

SQL/SQL 코딩 테스트-HackerRank

[HackerRank](E) Weather Observation Station 15

밀뿌 2022. 3. 25. 17:43

https://www.hackerrank.com/challenges/weather-observation-station-15/problem?isFullScreen=true 

 

Weather Observation Station 15 | HackerRank

Query the Western Longitude for the largest Northern Latitude under 137.2345, rounded to 4 decimal places.

www.hackerrank.com

 

[문제]

Query the Western Longitude (LONG_W) for the largest Northern Latitude (LAT_N) in STATION that is less than 137.2345. Round your answer to 4 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.

 

 

[답]

-mysql

select round(long_w,4) from station
where lat_N < 137.2345
order by lat_n desc
limit 1

주어진 조건보다 큰 값 중 가장 큰 lat_n에 대하여 long_w를 구해주는 문제이다.

가장 큰 값을 구하기 위해 order by를 desc로 정렬한 뒤 limit를 1 해주었다.

Comments