﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / TSQL and percentile (not percentilerank :) / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 05:37:38 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>[quote][b]dwain.c (1/3/2013)[/b] Given the power of SAS, if you can ever make it work it sounds like the makings of a great article![/quote]Indeed, I believe it would be.  I find it quite annoying to have to use the import wizard.  Per the SAS documentation, not all of the 4 providers support SQL operations, so there is that issue.  However, I tend to think that the way an ADO recordset handles the data access would be similar in nature to the way OPENROWSET would handle it.  Of course, that is just my totally uninformed speculation.  I'll keep plugging away at it, and if I do come up with a solution I'll certainly share the wealth.  One problem is that you only get the providers by having SAS installed on your machine.  Now, SAS does provide just the providers for free, but I have been unable to get them to work on my personal machine, where I don't have SAS installed.</description><pubDate>Fri, 04 Jan 2013 03:59:13 GMT</pubDate><dc:creator>Greg Snidow</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>[quote][b]Greg Snidow (1/3/2013)[/b][hr][quote][b]cs_source (1/3/2013)[/b] If you like i can post the SAS code? :)[/quote]Not the code for percentile, but if you can figure out a way to use OPENROWSET with the SAS OLE providers I would sure appreciate it.  I am able to use VBA in Excel to read SAS files, and to use the import wizard in SQL Server to import .sas7bdat files, but for the life of me I can't get OPENROWSET to work with the same SAS providers that Excel has no problem with.[/quote]Given the power of SAS, if you can ever make it work it sounds like the makings of a great article!</description><pubDate>Thu, 03 Jan 2013 19:18:51 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>[quote][b]cs_source (1/3/2013)[/b][hr]At this time i only use SAS for the percentile not for any other function so your solution is one step further than mine. When i review this hopefully within the next two weeks i'll focus on just getting this done in SQL.[/quote]Well, while I'm not intending to steer anyone away from SQL Server, as I use it for 95% of handling data, if you have a license for SAS, you would be well served to start learning how to program in it, as it is an extremely powerful tool, and because of the exorbitant annual license fee, most folks don't have access to it.  It is a good thing to be able to put on your resume.</description><pubDate>Thu, 03 Jan 2013 18:47:18 GMT</pubDate><dc:creator>Greg Snidow</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>At this time i only use SAS for the percentile not for any other function so your solution is one step further than mine. When i review this hopefully within the next two weeks i'll focus on just getting this done in SQL.</description><pubDate>Thu, 03 Jan 2013 16:21:19 GMT</pubDate><dc:creator>cs_source</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>[quote][b]cs_source (1/3/2013)[/b] If you like i can post the SAS code? :)[/quote]Not the code for percentile, but if you can figure out a way to use OPENROWSET with the SAS OLE providers I would sure appreciate it.  I am able to use VBA in Excel to read SAS files, and to use the import wizard in SQL Server to import .sas7bdat files, but for the life of me I can't get OPENROWSET to work with the same SAS providers that Excel has no problem with.</description><pubDate>Thu, 03 Jan 2013 12:28:33 GMT</pubDate><dc:creator>Greg Snidow</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>Hi Lynn &amp; Dwayne,I spent a few days trying to find an answer and found the closest value to be the first query i posted, however that query doesn't work for what i need. At this time i decided to go back to SAS to calculate the percentile, however i will be tackling this once i have a few things off my plate.If you like i can post the SAS code? :)</description><pubDate>Thu, 03 Jan 2013 11:11:09 GMT</pubDate><dc:creator>cs_source</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>Was your solution something like this?[code="sql"];WITH Scores (Score, Percentile) AS (    SELECT Score, NTILE(10) OVER(ORDER BY Score)    FROM sys.all_columns    CROSS APPLY (SELECT 51+ ABS(CHECKSUM(NEWID())) % 50) a(Score)    )SELECT ScoreFROM ScoresWHERE Percentile &amp;gt; 9[/code]</description><pubDate>Tue, 01 Jan 2013 18:44:26 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>[quote][b]cs_source (12/31/2012)[/b][hr]Thank you for the information. I would like to delete this topic as i have found my answer. After reading a bit it seems that we can't delete our own topics?[/quote]Having asked a question and upon finding your own answer, it is actually good forum etiquette to post how you solved your problem.  Others may come along with the same or similar question and your answer may help them.</description><pubDate>Mon, 31 Dec 2012 14:19:48 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>Thank you for the information. I would like to delete this topic as i have found my answer. After reading a bit it seems that we can't delete our own topics?</description><pubDate>Mon, 31 Dec 2012 14:13:15 GMT</pubDate><dc:creator>cs_source</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>If you can post some ddl, sample data and desired output you will find lots of people diving in to this one. Please see the first article in my signature for best practices when posting questions.</description><pubDate>Fri, 28 Dec 2012 14:51:00 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>so it seems like i spoke too soon, this formula only provides you with the row in the 90th percentile not the value.What i'm looking for is a 90th percentile value :(</description><pubDate>Fri, 28 Dec 2012 13:36:17 GMT</pubDate><dc:creator>cs_source</dc:creator></item><item><title>TSQL and percentile (not percentilerank :)</title><link>http://www.sqlservercentral.com/Forums/Topic1400991-392-1.aspx</link><description>Hi all,I would like to ask for some help and maybe the best practices on calculating the 90th percentile using TSQL. To be clear after searching online i'm looking for one value to show based on various numbers during a time frame. Example what is the 90th percentile for students duration of an exam for the week of July 1st.I believe i have figured out the formula below (which excludes NULLS)select max(case when rownum*1.0/numrows &amp;lt;= 0.9 then &amp;lt;column&amp;gt; end) as percentile_90thfrom (select &amp;lt;column&amp;gt;,             row_number() over (order by &amp;lt;column&amp;gt;) as rownum,             count(*) over (partition by NULL) as numrows      from &amp;lt;table&amp;gt;      where &amp;lt;column&amp;gt; is not null AND DATE = '12-17-2012' (etc)     ) tThere are now 2 items I’m still working on to complete this query at my workplace and that is:1 – get 2 decimal places as result (right now the output has no decimal places)2 – integrate the Date to be dynamic (for last week for example) -&amp;gt; replace static with DATE &amp;gt;= CONVERT(date, GETDATE() -8)Before i go ahead and spend more time i wanted to see what the community has for the best method to calculate percentile? i did a spot check and extracted the raw data and found this calculation is right on except for 1 date range i used and i'm not sure why right now.Any advice is appreciated!</description><pubDate>Fri, 28 Dec 2012 11:19:19 GMT</pubDate><dc:creator>cs_source</dc:creator></item></channel></rss>