I trying to use mysql to solve the following solutions: https://www.hackerrank.com/challenges/weather-observation-station-20/problem
Understanding that a variable cannot be put into LIMIT statement (from this )
My approach>
to declare a new variable to record rowIDs, and use rowID to retrieve the record in the middle. However, it seems that rowID is not working well. Could anyone give me some advises?
SELECT ROUND(COUNT(LAT_N)/2,0) FROM STATION into @count;
SELECT ROUND(a.LAT_N,4) FROM (
SELECT *,@row := @row + 1 FROM STATION s, (SELECT @row := 0) r
WHERE @row <=@count
ORDER BY s.LAT_N ASC) a
ORDER BY a.LAT_N DESC LIMIT 1;`