Weather Observation Station 20 | HackerRank
Query the median of Northern Latitudes in STATION and round to 4 decimal places.
www.hackerrank.com
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 LAT_N is the northern latitude and LONG_W is the western longitude.
[My Answer]
SELECT ROUND(A.LAT_N, 4)
FROM STATION A
WHERE (SELECT ROUND(COUNT(A.ID)/2) - 1 FROM STATION) =
(SELECT COUNT(B.ID) FROM STATION AS B WHERE B.LAT_N > A.LAT_N);
역시.. 안하다가 하려니까 오래걸린다..
'Code Problems > SQL_ HackerRank' 카테고리의 다른 글
[HackerRank] Population Census (0) | 2021.12.31 |
---|---|
[HackerRank] Placement (0) | 2021.12.30 |
[HackerRank] Weather Observation Station 19 (0) | 2021.11.26 |
[HackerRank] Weather Observation Station 18 (0) | 2021.11.26 |
[HackerRank] Weather Observation Station 17 (0) | 2021.11.14 |