How to get mean ,median , mode and range in a single select query?

后端 未结 3 1204
死守一世寂寞
死守一世寂寞 2021-01-27 09:06

I\'m trying to get mean, median, mode and range for a set of values in a table. I was able to get the average but median, range and mode I\'m getting a wrong one.

Below

3条回答
  •  别那么骄傲
    2021-01-27 10:03

    In SQL 2012 or later, it's often easier to use the percentile_cont function to calculate the median. It looks like the rest of your question has already been addressed, but I thought you'd want to know about this option as well.

    https://msdn.microsoft.com/en-us/library/hh231473.aspx

提交回复
热议问题