Link to home
Start Free TrialLog in
Avatar of dban00b
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!!
SELECT DISTINCT Item, Bid from dbo.ItemBids ORDER BY Bid DESC

Open in new window

Avatar of tigin44
tigin44
Flag of Türkiye image

SELECT DISTINCT [Bid]
FROM yourTable
SOLUTION
Avatar of tigin44
tigin44
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dban00b
dban00b

ASKER

I'll test these out and be right back.
Avatar of dban00b

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!