Weather Observation Station 20

Sort by

recency

|

3950 Discussions

|

  • + 0 comments

    Declare @total int SET @total = (Select Count(LAT_N) from Station);

    WITH median as( SELECT lat_n, ROW_NUMBER() OVER(ORDER BY lat_n) AS rn FROM station)

    Select CAST(AVG(CAST(LAT_N as DECIMAL(10,4))) as Decimal(10,4)) from median where median.rn in ((@total+1)/2, (@total+2)/2);

  • + 0 comments

    select round(lat_n,4) from (select row_number() over (order by lat_n) as rnk, lat_n from station ) as a

    where rnk = (select round(count(*)/2) from station)

    1-select round and lat_n 2- used row_number to lat_n to number the table 3- used where to count all row_number and divide in half to get median row_id

  • + 0 comments

    SET @rn := (Select count(lat_n) from station limit 1); SELECT ROUND(lat_n, 4) AS median FROM ( SELECT lat_n, ROW_NUMBER() OVER(ORDER BY lat_n) AS rn FROM station ) AS station WHERE station.rn = @rn / 2;

  • + 0 comments

    What the hell, dude? I can't use percentile, offset, i cant even use limit on where

    Well, there's my solution

    select truncate(max(lat_n),4) from (select lat_n from station order by lat_n limit 250) as alias;

  • + 0 comments

    Weather Observation Station 20

    SET @rn := (Select count(lat_n) from station limit 1); SELECT ROUND(lat_n, 4) AS median FROM ( SELECT lat_n, ROW_NUMBER() OVER(ORDER BY lat_n) AS rn FROM station ) AS station WHERE station.rn = @rn / 2;