Wednesday, October 9, 2019

No easy way to get the median in T-SQL?

I Googled against this some today and you have to write your own logic as best as I can tell. You can find all sorts of dueling examples online with no consensus. With SQL Server 2012 or greater I think there is a workaround with PERCENTILE_CONT. What if you have an even number of numbers and there is no number in the middle? It looks like the appropriate mathematics to average the two middlemost numbers in the sequence.

No comments:

Post a Comment