如何编写查询来查找表的最大值 [英] How to write query to find maximum value of table
本文介绍了如何编写查询来查找表的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
id User Bid_ID Amount
id1 manu bid67 3000
id2 vinu bid68 4000
id3 anu bid67 6000
id4 aju bid68 5500
id5 amal bid80 3500
id6 vinu bid80 8000
这是我的表格我想查找提高每个Bid_ID最大金额的详细信息
我所需的输出是上表是
this is my table i want to find details who raise the maximum Amount of each Bid_ID
my Desired output is of above table is
id User Bid_ID Amount
id3 anu bid67 6000
id4 aju bid68 5500
id6 vinu bid80 8000
我怎么写查询这个?
但是当我写查询时
how can i write query for this ?
but when I write query
SELECT bid_ID, user, MAX(Amount) AS Amount
FROM dbo.tbl_BidOffer
GROUP BY bid_ID, user
i得错了结果...
i got wrong result...
推荐答案
您的结果错误,因为您的查询将返回每个用户和Bid_ID组合的最高出价。您需要重新构建查询,以便找到单个Bid_ID的最高出价,然后将其链接回来以获取用户详细信息。
You get the wrong result because your query will return the maximum bid for each user and Bid_ID combination. You will need to restructure your query so that you can find the maximum bid for an individual Bid_ID, then link it back to get the user details.
这篇关于如何编写查询来查找表的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文