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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Returning records that exclude top 10% of values

Author  Topic 

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2008-03-06 : 09:14:26
I have data that looks like below (columns are Timestamp, Offered, Answered and Delay). I'm looking to exclude returning records that have a value for Delay that are within the top 10% of values of that column. Are there any 2005 tricks where this can be accomplished in a simple statement?

2008-02-18 08:30:00 23 22 173
2008-02-18 08:45:00 21 20 174
2008-02-18 09:00:00 24 25 230
2008-02-18 09:15:00 28 28 277
2008-02-18 09:30:00 25 22 159

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-06 : 09:33:01
Can you post you sample data with expected o/p to make your requirement clear?
Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2008-03-06 : 09:35:38
Sample data is in the original post along with this statement - "I'm looking to exclude returning records that have a value for Delay that are within the top 10% of values of that column".

I'm not sure how else to state the requirement.
Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2008-03-06 : 10:29:03
I found using NTILE in combination with a CTE helps me plot my data into percentiles the way I need to. Then I can ignore certain records based on that. I used the following URL as an example: http://weblogs.sqlteam.com/jeffs/archive/2008/02/21/Top-N-Percent-per-Group.aspx
Go to Top of Page
   

- Advertisement -