dban00b
asked on
SQL SELECT DISTINCT on only one column
I should be able to figure this out, but I'm being lazy....
How do I use the DISTINCT but on only one column?
Given the table:
Item Bid
1 100.00
2 100.00
3 100.00
1 150.00
3 125.00
1 175.00
What query do I use to get back the result set:
Item Bid
1 175.00
2 100.00
3 125.00
Obviously the attached query isn't working, because each ROW is DISTINCT, so I'm getting back everything.
Thanks!!
How do I use the DISTINCT but on only one column?
Given the table:
Item Bid
1 100.00
2 100.00
3 100.00
1 150.00
3 125.00
1 175.00
What query do I use to get back the result set:
Item Bid
1 175.00
2 100.00
3 125.00
Obviously the attached query isn't working, because each ROW is DISTINCT, so I'm getting back everything.
Thanks!!
SELECT DISTINCT Item, Bid from dbo.ItemBids ORDER BY Bid DESC
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll test these out and be right back.
ASKER
tigin - you were on the right track, but I wanted the max bid for each item, not the mininum item for each bid.
reb- you finished it up!
Thanks guys!
reb- you finished it up!
Thanks guys!
FROM yourTable