<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx</link><description>95% of statisticians may be offended at this post. Unfortunately, I’m going to be showing my ignorance about statistics here, I’m sure. I may even use Wikipedia to back up my arguments, which will offend many more of you. Someone (ok, it was Wes Brown</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38012</link><pubDate>Tue, 23 Aug 2011 10:42:19 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38012</guid><dc:creator>RichB</dc:creator><description>&lt;p&gt;Being lazy I just take the top 5 percent ordered desc, and take the top 1 off that ordered asc.&lt;/p&gt;
&lt;p&gt;ie&lt;/p&gt;
&lt;p&gt;select top 1 * from (select top 5 percent * from table ordered by val desc) ordered by val asc&lt;/p&gt;
&lt;p&gt;Sure, it's ugly, but it's easy :)&lt;/p&gt;</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38013</link><pubDate>Tue, 23 Aug 2011 11:16:59 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38013</guid><dc:creator>Rob Farley</dc:creator><description>&lt;p&gt;Yeah, there are definitely a bunch of ways you can work out what you count as your 95th. This method was as much an exercise in picturing a solution as anything, and trying to be sure of how things work when you don't have a nice round number.&lt;/p&gt;
</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38037</link><pubDate>Wed, 24 Aug 2011 07:19:05 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38037</guid><dc:creator>Alex Whittles</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;Very interesting post and a great technique, thanks for sharing it.&lt;/p&gt;
&lt;p&gt;The difference between your approach and any technique using stddev is essentially whether you want the top % of a sample or of the entire population. Stddev takes the limited sample data available and projects the distribution characteristics of the much larger unknown population.&lt;/p&gt;
&lt;p&gt;Both techniques are equally valid, and as you pointed out, depend on what definition of percentile is required. I.e. Do you have all available data or just a sample of it.&lt;/p&gt;
&lt;p&gt;Given this, hopefully you should avoid a bashing from the stats folk!&lt;/p&gt;</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38039</link><pubDate>Wed, 24 Aug 2011 07:47:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38039</guid><dc:creator>Rob Farley</dc:creator><description>&lt;p&gt;Ah, true. And hopefully statisticians won't mind my method either. Thanks Alex.&lt;/p&gt;
</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38068</link><pubDate>Thu, 25 Aug 2011 14:14:07 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38068</guid><dc:creator>Geoff</dc:creator><description>&lt;p&gt;What I did at one point in time in algorithm/psuedo-code form&lt;/p&gt;
&lt;p&gt;-get the total number of the set &lt;/p&gt;
&lt;p&gt;-get the ideal index (0.95 * N)&lt;/p&gt;
&lt;p&gt;-get the entry right below that index and right above&lt;/p&gt;
&lt;p&gt;-take the value of the one below&lt;/p&gt;
&lt;p&gt;-take the difference of the one below and above&lt;/p&gt;
&lt;p&gt;-add the fractional difference based on the index between the two numbers to the lower value&lt;/p&gt;
&lt;p&gt;I hope that makes sense. If I want greater speed I just round and use the top function or row_number functions.&lt;/p&gt;</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38069</link><pubDate>Thu, 25 Aug 2011 15:20:19 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38069</guid><dc:creator>Rob Farley</dc:creator><description>&lt;p&gt;Yes, that's the algorithm I applied here. But you have to make sure you subtract one and add it back again afterwards, because if you have just two numbers, you have one range between those two. Your point should be 1.95 not 1.9.&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;
</description></item><item><title>re: T-SQL thoughts about the 95th percentile</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#38136</link><pubDate>Mon, 29 Aug 2011 19:20:47 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38136</guid><dc:creator>Lars Hammarberg</dc:creator><description>&lt;p&gt;&amp;quot;95% of statisticians may be offended at this post&amp;quot;&lt;/p&gt;
&lt;p&gt;Hilarious! Thank you!&lt;/p&gt;
&lt;p&gt;/Lars H&lt;/p&gt;</description></item><item><title>Analytic functions – they’re not aggregates</title><link>http://sqlblog.com/blogs/rob_farley/archive/2011/08/23/t-sql-thoughts-about-the-95th-percentile.aspx#42754</link><pubDate>Tue, 10 Apr 2012 01:53:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42754</guid><dc:creator>Rob Farley</dc:creator><description>&lt;p&gt;SQL 2012 brings us a bunch of new analytic functions , together with enhancements to the OVER clause&lt;/p&gt;
</description></item></channel></rss>