Home Forums SQL Server 2008 SQL Server 2008 - General Calculating Median, Max, Min, Lower Quartile and Upper Quartile for a Boxchart? RE: Calculating Median, Max, Min, Lower Quartile and Upper Quartile for a Boxchart?

  • Thanks a ton, Dwain.

    Just for background (may not be needed) here are a couple of links regarding the math for box-and-whisker charts (or box plots)

    http://www.purplemath.com/modules/boxwhisk.htm

    https://www.khanacademy.org/math/probability/descriptive-statistics/Box-and-whisker%20plots/v/box-and-whisker-plots

    Essentially, I need five things: median, upper quartile, lower quartile, min, and max. Median, min, and max are pretty self explanatory. The lower quartile for a box plot takes the median of all of the numbers below the median for the entire set. The upper quartile takes the median for all the numbers above the median for the entire set.

    With that in view, here should be the result set for my sample DDL:

    Year Median Max Min LowerQ UpperQ

    2010 90 99 81 88 92

    2011 76 88 69 72.5 84.5

    2012 90.5 97 72 86.5 94.5

    Again, thanks alot for taking this on. If I can provide further explanation, please let me know!