You are viewing a single comment's thread. Return to all comments →
DECLARE @TotalCount INT = ( SELECT COUNT(*) FROM STATION WHERE [LAT_N] IS NOT NULL ); WITH SortedNL AS ( SELECT [LAT_N], ROW_NUMBER() OVER(ORDER BY [LAT_N]) AS SortedIndex FROM STATION WHERE [LAT_N] IS NOT NULL ) SELECT CAST( CASE WHEN(@TotalCount % 2 = 0) THEN AVG([LAT_N]) ELSE MAX([LAT_N]) END AS DECIMAL(10,4) ) AS Median FROM SortedNL WHERE SortedIndex IN ( (@TotalCount + 1) / 2, (@TotalCount + 2) / 2 );
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 →