all groups > sql server programming > august 2003 >
You're in the

sql server programming

group:

special top 3


special top 3 u50415039 NO[at]SPAM spawnkill.ip-mobilphone.net
8/28/2003 9:23:39 PM
sql server programming:
SELECT *
FROM tbl AS n1
WHERE score in ( SELECT TOP 3 score FROM tbl AS n2
WHERE n1.name = n2.name order by score desc)

my query won't give me the result i like.

teamA MARK1 20
MARK5 14
MARK3 10
MARK4 08
MARK2 14

teamB fred2 12
fred1 14
fred3 10
fred4 08
fred5 14
fred6 03

result:

teamA mark1 20 mark2 14 mark3 10
mark5 14

teamB fred1 14 fred2 12 fred3 10
fred5 14

rick





--
Sent by ricksql from yahoo in field com
This is a spam protected message. Please answer with reference header.
Re: special top 3 Jens Süßmeyer
8/29/2003 12:06:59 AM
Hello Rick !

Please post some DDL and test Data that we can see the logical structure of
these tables. Are there two or one table (seems that there is one). What do
you want to achive ? Get the 3 highest scores of all participants?

Jens Süßmeyer.

Re: Re: special top 3 u50415039 NO[at]SPAM spawnkill.ip-mobilphone.net
8/29/2003 2:22:28 PM
Dear Jens Süßmeyer,

In your posting Re: special top 3 from Fri, 29 Aug 2003 00:06:59 +0200
you write:

[quoted text, click to view]

what would be the query to obtain top 3 players with highest scores
from (A) to put it in (B) format?.

(A)
Table:

Team Name score
----- ----- ------
teamA MARK1 20
MARK5 14
MARK3 10
MARK4 08
MARK2 14
teamB fred2 12
fred1 14
fred3 10
fred4 08
fred5 14
fred6 03

(B)

teamA mark1 20 mark2 14 mark3 10
mark5 14

teamB fred1 14 fred2 12 fred3 10
fred5 14

Rick










--
Spam protected message from:
Sent by ricksql from yahoo piece from com
AddThis Social Bookmark Button