Weather Observation Station 20

  • + 8 comments

    for sql server users, there is a built in function that helps you with percentiles. percentile_disc is used to find a row in a set of records which is the nth percentile of that set. The median is the 50th percentile of any set.

    the syntax is: PERCENTILE_DISC (percentile you are looking for) WITHIN GROUP (the column in which you need to find your percentile) OVER (you can, but arent required to, PARTITION BY another column, but you can't use an ORDER BY since that is taken care of in the WITHIN GROUP clause)

    select distinct
      cast(
         round(
           PERCENTILE_DISC (.5) WITHIN GROUP (order by lat_n) OVER()
         ,4) 
       as decimal(16,4))
    from station