We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
select case
when mod(@tot,2)=0 then
(select round(avg(lat_n),4) from (select *,row_number() over (order by lat_n) as rown from station) sub where rown=(@tot/2) or rown=(@tot/2-1))
else
(select round(lat_n,4) from (select *,row_number() over (order by lat_n) as rown from station) sub where rown=ceil(@tot/2))
end;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 20
You are viewing a single comment's thread. Return to all comments →
set @tot = (select count(id) from station);
select case when mod(@tot,2)=0 then (select round(avg(lat_n),4) from (select *,row_number() over (order by lat_n) as rown from station) sub where rown=(@tot/2) or rown=(@tot/2-1)) else (select round(lat_n,4) from (select *,row_number() over (order by lat_n) as rown from station) sub where rown=ceil(@tot/2)) end;