Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2008, 08:23 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Quote:
quote:Originally posted by dparsons
 Marvelous example Jeff. Nicely done. =]


Thanks, Doug...

--Jeff Moden
 
Old March 25th, 2008, 08:25 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Quote:
quote:Originally posted by rstelma
 Hey Jeff,

Excellent example and solution. I was wondering about the WITH TIES clause. Without it the query still pulls Jay at 60 and Joe at 60 but not Jan at 60. Why is that?

Thanks,
Richard
Because it's no longer considering ties in the top 3 scores... it's just considering the top 3 "places" in descending order without any consideration for ties.

--Jeff Moden
 
Old March 26th, 2008, 08:39 AM
Authorized User
 
Join Date: Mar 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the help folks.. Now I have to look up "WITH TIES" to get a better understanding of how it works.

 
Old March 26th, 2008, 01:45 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Perfect... thanks for the feedback Joe... If you can't find anything to your satisfaction, lemme know and I'll try to explain better. One way of explaining it is to lookup RANKING in WikiPedia... then look for "DENSE RANKING (1223)". THAT's what "WITH TIES" sort of does...

Here's what it says...

 
Quote:
quote:Dense ranking ("1223" ranking)In dense ranking, items that compare equal receive the same ranking number, and the next item(s) receive the immediately following ranking number. Equivalently, each item's ranking number is 1 plus the number of items ranked above it that are distinct with respect to the ranking order.
Quote:

Thus if A ranks ahead of B and C (which compare equal) which are both ranked ahead of D, then A gets ranking number 1 ("first"), B gets ranking number 2 ("joint second"), C also gets ranking number 2 ("joint second") and D gets ranking number 3 ("third").
...and here's the link... http://en.wikipedia.org/wiki/Ranking

SO... let's say you have 1,2,2,2,2,2,3,4,4 and you ask for the TOP 3 WITH TIES, you'll get back everyone with the Top 3 scores...

1,2,2,2,2,2,3

If you ask for the TOP 3 but without ties, you get back the top 3 rows regardless...

1,2,2


--Jeff Moden
 
Old March 26th, 2008, 05:11 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Jeff,

Thanks for the explanation of WITH TIES. Very much appreciated. Thank you.

Richard

 
Old March 27th, 2008, 08:27 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Quote:
quote:Originally posted by rstelma
Jeff,
Thanks for the explanation of WITH TIES. Very much appreciated. Thank you.

Richard
Thanks for the feedback, Richard... it's the best "payment" anyone could hope for on forums like this.

--Jeff Moden
 
Old March 27th, 2008, 11:29 AM
Authorized User
 
Join Date: Mar 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes Jeff, THANK YOU for the explanation on WITH TIES. I'd never seen it before, but now I know I'll be using it!!

 
Old March 27th, 2008, 11:48 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Yeah. I understand. I contribute when I can. What I've learned here has made it possible for me to work in this industry. I'm very grateful for that.

And it's cool to be appreciated.

Richard






Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek help for select Month in list box apple88 Classic ASP Databases 1 October 11th, 2007 01:11 PM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
SELECT TOP n NOT SELECTING TOP n! ibi SQL Language 8 March 30th, 2005 08:08 PM
Crystal reports 10.0 Query about showing top N rec rajdotme Crystal Reports 1 June 12th, 2004 03:35 AM
Retrieve top 10 bmains XSLT 1 January 5th, 2004 02:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.