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 2000 Forums
 Transact-SQL (2000)
 MAX with INNER JOIN??

Author  Topic 

Nmarconi
Starting Member

2 Posts

Posted - 2006-04-11 : 12:05:40
I am having trouble using the max function. I have 3 tables (Bids, Players, Teams) The Bids Table contains Bids.BidId, Bids.BidTeam, Bids.BidPlayer and Bids.BidPrice

First I want to just display only the rows consisting of the highest BidPrice for each BidPlayer

I can get this to work, but not with BidTeam:

SELECT Bids.BidPlayer, MAX (Bids.BidPrice)
FROM Bids
GROUP BY Bids.BidPlayer

How do I add the Bids.BidTeam? When I use the satement below, it doesnt work:

SELECT Bids.BidPlayer, Bid.BidTeam, MAX (Bids.BidPrice) FROM Bids GROUP BY
Bids.BidPlayer, Bid.BidTeam

Last question, I want to use INNER JOIN to then replace Bids.BidPlayer with Players.Name (via Players.PlayerID, which is the value held in Bids.BidPlayer) Is this possible?

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-04-11 : 12:08:55
Add an s to the Bid.BidTeam to be Bids.BidTeam..

Yes, the inner join is possible..
Go to Top of Page

Nmarconi
Starting Member

2 Posts

Posted - 2006-04-11 : 12:12:13
quote:
Originally posted by RickD

Add an s to the Bid.BidTeam to be Bids.BidTeam..

Yes, the inner join is possible..



Sorry there is an s there, but the problem is that it returns too many results - i think it is returning the max BidPrice for each combo of BidPlayer and BidTeam

I want it to only return the highest BidPrice for each BidPlayer then also supply which BidTeam is in that row.

Sorry If i dont explain things well, I am very new to SQL
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-04-11 : 12:56:39
Use MAX on BidTeam as well then..
Go to Top of Page
   

- Advertisement -