Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Percentile Calculation

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2012-10-05 : 11:48:40
Hi ~

Is it possible to calculate percentiles in sql as in excel? I have a range of scores and I would like to determine who is in the top 10%, mid 50%, etc.

If so, how can it be done?

Thanks!



sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-05 : 12:14:35
Excel uses different calculations based on whether a given value is in the dataset or not. If you want to reproduce the same behavior in SQL, take a look at this article, they the formulas, description and example code: http://www.sqlmag.com/article/tsql3/calculate-percentiles Both approaches use rank/dense_rank functions.
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2012-10-05 : 12:26:53
OK, thanks!
Go to Top of Page
   

- Advertisement -