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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-06-22 : 09:53:56
|
Bryan writes "Hello, and thank you in advance for any help you can give.I'm trying to design a query to pull multiple rows from one table, and a single row from another table where an auction Id would be equal in both tables. Here's the setupTable 1AuctionID - PKAuctionNameAuctionDateAuctionOptions...Table 2AuctionID - FKBidIDBidAmountBidder...Every record existing in table 1 should be returned, and only the TOP record from table two as an expression, giving me the high bid amount for each auction, since each auction will have multiple bids, I need only the top record.Thanks for all your help" |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2006-06-22 : 09:58:09
|
SELECT a.AuctionID, a.ActionName, ISNULL(MAX(b.BidAmount), 0) AS HighestBidFROM table1 a LEFT OUTER JOIN table2 b ON a.AuctionID = b.a.AuctionIDGROUP BY a.AuctionID, a.ActionName--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
|
|
|
|
|