Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old March 25th, 2008, 08:23 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
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
Reply With Quote
  #12 (permalink)  
Old March 25th, 2008, 08:25 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
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
Reply With Quote
  #13 (permalink)  
Old March 26th, 2008, 08:39 AM
Authorized User
Points: 254, Level: 5
Points: 254, Level: 5 Points: 254, Level: 5 Points: 254, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: , , .
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.

Reply With Quote
  #14 (permalink)  
Old March 26th, 2008, 01:45 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
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
Reply With Quote
  #15 (permalink)  
Old March 26th, 2008, 05:11 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
  #16 (permalink)  
Old March 27th, 2008, 08:27 AM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
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
Reply With Quote
  #17 (permalink)  
Old March 27th, 2008, 11:29 AM
Authorized User
Points: 254, Level: 5
Points: 254, Level: 5 Points: 254, Level: 5 Points: 254, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: , , .
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!!

Reply With Quote
  #18 (permalink)  
Old March 27th, 2008, 11:48 AM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.