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
|
3942 Discussions
|
Please Login in order to post a comment
WITH cte AS ( SELECT TOP 1 PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY LAT_N)
OVER () AS median FROM Station )
select ROUND(CAST(median as decimal (10,4)),4) from cte;
WITH ORDERLIST AS( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS ROWASC, ROW_NUMBER() OVER (ORDER BY LAT_N DESC) AS ROWDESC FROM STATION ),
MEDIANS AS( SELECT LAT_N FROM ORDERLIST WHERE ROWASC=ROWDESC OR ROWASC +1 = ROWDESC ) SELECT ROUND (AVG(LAT_N * 1.0),4)AS MEDIAN FROM MEDIANS;
A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to decimal places.
WITH ROW_NUMS AS ( SELECT LAT_N, ROW_NUMBER() OVER(ORDER BY LAT_N) AS ROW_NUM, COUNT(*) OVER() AS TOTAL_NO_ROWS FROM STATION ), MID_VALS AS( SELECT LAT_N FROM ROW_NUMS WHERE ROW_NUM IN ( FLOOR((TOTAL_NO_ROWS+1)/2), CEIL((TOTAL_NO_ROWS+1)/2) ) ) SELECT ROUND(AVG(LAT_N), 4) AS MEDIAN FROM MID_VALS;
Select Round(avg(lat_n),4) From ( Select Lat_n, row_number() over(order by lat_n asc) as RN, Count(*) over() as TR From Station ) as SQ Where RN = CEIL(TR/2) or RN = Floor(TR/2)+1;