Hello coders, today we are going to solve Weather Observation Station 20 HackerRank Solution in SQL.
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.
The STATION table is described as follows:
where LAT_N is the northern latitude and LONG_W is the western longitude.
Solution – Weather Observation Station 20 in SQL
SET @r = 0; SELECT ROUND(AVG(Lat_N), 4) FROM (SELECT (@r := @r + 1) AS r, Lat_N FROM Station ORDER BY Lat_N) Temp WHERE r = (SELECT CEIL(COUNT(*) / 2) FROM Station) OR r = (SELECT FLOOR((COUNT(*) / 2) + 1) FROM Station)
Disclaimer: The above Problem (Weather Observation Station 20) is generated by Hacker Rank but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.