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
|
3977 Discussions
|
Please Login in order to post a comment
SELECT round(lat_n,4) FROM ( SELECT lat_n, ROW_NUMBER() OVER (ORDER BY lat_n) rn,count(*) over() total_rows FROM station ) WHERE rn = ( CASE WHEN MOD(total_rows, 2) = 1 THEN (total_rows + 1) / 2 ELSE ((total_rows / 2) + ((total_rows / 2) + 1)) / 2 END );
SELECT CAST(AVG(LAT_N) AS DECIMAL(10,4)) AS median_lat FROM ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS rn, COUNT(*) OVER () AS total_count FROM STATION ) t WHERE rn IN ((total_count + 1) / 2, (total_count + 2) / 2);
MySQL:
Running code in MySQL
WITH Ordered AS ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS rn, COUNT(*) OVER () AS total FROM STATION ) SELECT ROUND(AVG(LAT_N), 4) AS median_lat_n FROM Ordered WHERE rn IN ((total + 1) / 2, (total + 2) / 2);