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.
with cte as(
SELECT
LAT_N,
ROW_NUMBER()OVER(Order By ROUND(LAT_N,4) ASC) rn
FROM STATION
) ,
ctern as(
Select Floor(MAX(rn)/2) as marn,ceiling(MAX(rn)/2) as mirn,Count(*) co From cte
)
Select round(Avg(LAT_N),4) from cte
WHERE 1= Case when Round(MOD(rn,2))=0 AND rn = (Select marn from ctern) or rn = (Select mirn from ctern) then 1
WHEN Round(MOD(rn,2))=1 AND rn = (Select mirn from ctern) then 1
Else 0 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 →
with cte as( SELECT LAT_N, ROW_NUMBER()OVER(Order By ROUND(LAT_N,4) ASC) rn FROM STATION ) , ctern as( Select Floor(MAX(rn)/2) as marn,ceiling(MAX(rn)/2) as mirn,Count(*) co From cte ) Select round(Avg(LAT_N),4) from cte WHERE 1= Case when Round(MOD(rn,2))=0 AND rn = (Select marn from ctern) or rn = (Select mirn from ctern) then 1 WHEN Round(MOD(rn,2))=1 AND rn = (Select mirn from ctern) then 1 Else 0 END