Weather Observation Station 20

Sort by

recency

|

3802 Discussions

|

  • + 0 comments

    WITH Ordered AS ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS RowNum, COUNT(*) OVER () AS TotalRows FROM STATION ) SELECT ROUND(AVG(LAT_N), 4) AS Median_Latitude FROM Ordered WHERE RowNum IN (FLOOR((TotalRows + 1) / 2), CEIL((TotalRows + 1) / 2));

  • + 0 comments
    WITH Lati_Table AS (
      SELECT LAT_N, ROW_NUMBER() OVER(ORDER BY LAT_N ASC) as row_num,
             COUNT(*) OVER() as total_count
      FROM STATION
    )SELECT ROUND(LAT_N,4) FROM Lati_Table WHERE row_num = (total_count+1)/2;
    
  • + 0 comments

    SELECT ROUND(LAT_N, 4) FROM ( SELECT LAT_N, ROW_NUMBER() OVER (ORDER BY LAT_N) AS row_num, COUNT(*) OVER () AS total_count FROM STATION ) temp WHERE row_num = (total_count + 1) / 2 OR row_num = (total_count / 2) + 1;

  • + 1 comment

    Why does this not work?

    select round(s.lat_n,4) from (
        SELECT lat_n 
    		FROM station
    		ORDER BY lat_n
    		limit (select ceil(count(*) / 2) from station)) as s
    order by s.lat_n desc limit 1 ;
    
  • + 0 comments

    This one for SQL server:

    select cast (lat_n as decimal(8,4)) 
    from (
        select id , lat_n , 
        row_number() over (order by lat_n) as rowNum
        from station
    ) temp
    where rowNum=CEILING((select count(id)/2 from station))+1;