Question of the Week Answer

Last Week’s Challenge…

Answer

Sometimes new is better. Or at least it is in this case, wethinks:

What new SQL Server 2012 function can help you perform a median calculation in T-SQL much more easily than you could in previous versions?

And the winner is…

AnswerOur winner is Neeraj, who provided the correct answer: PERCENTILE_CONT.

Although many people answered PERCENTILE_CONT and PERCENTILE_DISC (and PERCENTILE_COUNT), PERCENTILE_CONT is the only correct answer. The reason? PERCENTILE_CONT calculates an interpolated value (a.k.a. an average) at the 50th percentile. PERCENTILE_DISC, on the other hand, must return an actual value. While this might not make a difference for larger datasets, it means that PERCENTILE_DISC cannot be used to calculate a true median.

Congrats, Neeraj! Your $50 gift card is on its way!