HackerRank-Aggregation-Weather Observation Station 20
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:
**My solution **
SELECT ROUND(LAT_N,4)
FROM
(
SELECT ROW_NUMBER() OVER(ORDER BY LAT_N asc) AS NUM,LAT_N
FROM STATION
)
WHERE NUM=(SELECT ROUND(COUNT(*) / 2)
FROM STATION
);
Comments