I have been trying to solve this problem : https://www.hackerrank.com/challenges/weather-observation-station-20/problem?isFullScreen=true
It states to find the median, but everytime I am ending up with syntax error or runtime error.
SELECT ROUND(LAT_N, 4)
FROM STATION
ORDER BY LAT_N
LIMIT 1 OFFSET (
SELECT
CASE
WHEN COUNT(LAT_N) % 2 <> 0 THEN COUNT(LAT_N) / 2
ELSE (COUNT(LAT_N) - 1) / 2
END
FROM STATION
);
This is the solution that I have worked upon. Any help is highly appreciated.