Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
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

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
SQL
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
SQL
SELECT     bid_ID, user, MAX(Amount) AS Amount
FROM         dbo.tbl_BidOffer
GROUP BY bid_ID, user 

i got wrong result...
Posted
Updated 13-May-13 16:17pm
v2
Comments
Sergey Alexandrovich Kryukov 13-May-13 22:06pm    
What prevents you from simply reading the SQL reference?
—SA

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900