How do I join a row from one table to a row with the MAX value for a given column on another table?
For example, I have a auctions table and an auction_bids table. I want to join the auctions table with the highest bid for that auction (i.e. highest value for column bid_amount AND where auction_id = x) in the auction_bids table.
It’s annoyingly complicated. You’d be better off with a “winner” flag in each winning auction_bid.
Note that auctions with zero bids will not be listed at all, and auctions with ties (can that happen?) will appear once for each tied bid.