Weather Observation Station 20

Sort by

recency

|

3711 Discussions

|

  • + 0 comments

    WITH CTE as ( Select LAT_N, ABS(ROW_NUMBER() OVER (Order By LAT_N) - ROW_NUMBER() OVER (Order By LAT_N desc)) ROW# FROM STATION)

    Select CAST(AVG(LAT_N) as decimal(38,4)) from CTE WHERE ROW# in (Select MIN(ROW#) From CTE);

  • + 1 comment

    Here's my solution ... please share your thoughts ...

    with cols as 
    (
        select lat_n,
        ROW_NUMBER() OVER (ORDER BY lat_n) AS row_num
        from station
    )
    
    select round(lat_n,4)
    from cols
    where row_num = (select ceil(count(lat_n)/2) from station);
    
  • + 0 comments

    WITH RankedStations 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 ) SELECT ROUND( AVG(LAT_N), 4 ) AS median FROM RankedStations WHERE RowAsc = RowDesc OR RowAsc + 1 = RowDesc;

  • + 0 comments

    SELECT CAST(ROUND(AVG(LAT_N),4) AS DECIMAL(10,4)) AS median FROM ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS row_num, COUNT(*) OVER () AS total_count FROM STATION ) AS ranked_data WHERE row_num = (total_count + 1) / 2;

  • + 0 comments
    with tmp as (
        select lat_n
        , row_number() over () as num
        from station
        order by lat_n
    )
    select round(lat_n, 4) 
    from tmp
    where num = (select max(num) from tmp) div 2 + 1