[HackerRank] Weather Observation Station 20

mzzzi·2022년 4월 25일
0

HackerRank SQL

목록 보기
42/52
post-thumbnail

MySQL >

Weather Observation Station 20

A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to 4 decimal places.

Input Format
The STATION table is described as follows:

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


*참고
PERCENT_RANK()
0 부터 1까지의 값을 반환한다.
partition이나 result set안에서의 first row에 대해서는 항상 0을 반환한다.
반복되는 값이라면 같은 값을 반환한다._


My Answer


SELECT ROUND(S.LAT_N, 4)
FROM (SELECT PERCENT_RANK() OVER(ORDER BY LAT_N) PER, LAT_N
      FROM STATION) S
WHERE S.PER = 0.5 ;
profile
무럭무럭 성장하라🌳

0개의 댓글