MySQL表,包含姓名,电子邮件,auction_id和出价。我在尝试使用GROUP by auction_id时,从最高出价行获取MAX出价和电子邮件地址。
我可以获得退回的最高出价金额,但返回的电子邮件地址不是MAX出价。
SELECT email, MAX(bid) FROM `kisd_wdm_bidders` GROUP BY auction_id
答案 0 :(得分:3)
你必须SELECT T1.auction_id,T1.email,T1.bid
FROM kisd_wdm_bidders AS T1
INNER JOIN (
SELECT auction_id, MAX(bid) AS max_bid
FROM kisd_wdm_bidders
GROUP BY auction_id
) AS T2
ON T1.auction_id = T2.auction_id AND T2.max_bid =T1.bid
(不准确)
{{1}}
希望这有帮助。
答案 1 :(得分:1)