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
|
3957 Discussions
|
Please Login in order to post a comment
SQL SERVER SELECT CAST(ROUND(MedianValue, 4) AS DECIMAL(10,4)) AS Median FROM ( SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY LAT_N) OVER () AS MedianValue FROM STATION ) AS Sub GROUP BY MedianValue;
SET @Num_row := -1;
SELECT
WHERE Num_row IN (FLOOR(@Num_row/2),CEIL(@Num_row/2));
WHERE Num_row IN (FLOOR(@Num_row/2),CEIL(@Num_row/2));
with ordered as ( select lat_n, row_number() over (order by lat_n) as row_num from station ), counts as ( select count(lat_n) as total from ordered ), median_vals as ( select o.lat_n, c.total from ordered o cross join counts c where o.row_num = floor((c.total + 1)/2) or o.row_num = ceil((c.total + 1)/2) ) select round(avg(lat_n), 4) as median from median_vals;
SELECT ROUND(LAT_N,4) FROM(SELECT LAT_N, PERCENT_RANK() OVER (ORDER BY LAT_N) percent FROM STATION) a WHERE percent = 0.5;