I am currently writing a basic charity online auction asp application for our intranet. All the bids are in a bid table which has fields for
BidID, ItemID, BidTime, and BidValue.
The ItemID joins to an Item table to get the ItemName.
The BidderID joins to a Bidder table to get the BidderName.
I am trying to write a query that will generate a list of all items, the current winning bidder and the Winning bid. But I am struggling with this.
I can get a list of WinnningBids and ItemIDs with the below,
SELECT MAX(BidValue) AS MaxBid, ItemID, BidderID
FROM Bid
GROUP BY ItemID, BidderID
but if 2 people have bid the same it must go to the one with the earlier bid time (and I must allow same bids so it can go to the second person if the first person claims not to have bidded!)
Any ideas how I could go about this in one query?
