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.
Weather Observation Station 20
Weather Observation Station 20
Sort by
recency
|
3750 Discussions
|
Please Login in order to post a comment
WITH OrderValue AS ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS row_num, COUNT(*) OVER () AS total_count FROM STATION ) SELECT ROUND(AVG(LAT_N),4) AS median FROM OrderValue WHERE row_num IN ((total_count + 1) / 2, (total_count + 2) / 2);
In MySQL, with rn as (select row_number() over (order by lat_n) as rownumber, lat_n, count(*) over() as c from station) select round(avg(lat_n),4) from rn where rownumber in ((c/2) + 1, (c+1)/2) ;
SET @ec = (SELECT COUNT(lat_n) FROM station);
WITH med AS (Select * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY Lat_n) as rn, Lat_n, LEAD(lat_n,1) OVER (ORDER BY lat_n) as x FROM Station ) AS temp WHERE rn=(CEILING(@ec/2)) ) SELECT case WHEN @ec%2=1 THEN ROUND(lat_n,4) WHEN @ec%2=0 THEN ROUND((lat_n+x)/2,4) END FROM med
;