Hello
I am not very strong in sql and was wondering if anybody could help me with the following query. I have a silent auction and people are adding their bids for various items. Nobody knows what anyone else bids on anyitem
(**** to delimit each column and value
--table name : BID--
bid_id*****FK_item_id*****bidder_name*****amount
-----------------------------------------------
1*****3*****bill*****5.00
7*****2*****allison*****7.00
2*****3*****allison*****6.00
3*****1*****andrew*****5.00
6*****3*****john*****8.00
4*****2*****bill*****1.25
5*****1*****mathew*****10.00
8*****3*****mike*****5.00
I was hoping to return the highest bid for each item as well as the name of the bidder for that highest bid. I am not having any luck.
I would like to see this as the result
FK_item_id*****bidder_name*****amount
-----------------------------------------------
1*****mathew*****10.00
2*****allison*****7.00
3*****john*****8.00
I can return the highest amount and fk_item_id for each item but as soon as I try to add the name, it doesn't work. What am I doing wrong?
here is my sql that works
I would like to do thisCode:SELECT FK_item_id, max(amount) FROM bid group by FK_item_id
Is this not working because bidder_name is not uniqueCode:SELECT FK_item_id, bidder_name, max(amount) FROM bid group by FK_item_id
Please help![]()
bsw




Reply With Quote