[thelist] SQL Server 2008 - How to get the 95% percentile?

Luther, Ron Ron.Luther at hp.com
Tue Jun 14 16:09:24 CDT 2011


Rudy and Anthony both suggested ways to try to get the 95% percentile

>>   SELECT AVG(score) 
>>     FROM ( SELECT TOP 95 PERCENT WITH TIES score 
>>              FROM dbo.TestScores
>>            ORDER 
>>                BY score DESC
>>          ) AS Top95PercentAvg
   

Hi Guys!

Very nice.  Big thanks!  Yeah, I knew subquery was the way to go, but I wasn't sure about the syntax.  And the little googling I did was leading me on a merry chase through the NTILE() command and the 'over' clause.  Ick.

There is a little trickiness though.  For measures where 'larger' is 'better', I think you may have to take the top 95% records *ascending* ... and then grab the *max* value from that set.  I believe that should give you the value for the 95% percentile.  

Thanks Much!
RonL.



More information about the thelist mailing list