Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return only lowest value 2

Status
Not open for further replies.

lk2fsh

Technical User
May 17, 2005
2
0
0
US
Three different suppliers supply an identical part. How do I run a query to return only the lowest priced record.

I.E.

Part Number Supplier Price

3 33 $34
3 22 $35
3 12 $29

I would like to return only the record that shows the last row. I know how to do a query, just don't know how to make it select only this lowest value.

Thanks
 
SELECT TableParts.*
FROM TableParts WHERE ((TableParts.PartNumber=YourChoice) AND ((TableParts.Price)=(select Min(Price) from TableParts where PartNumber=YourChoice)));
 
Another way:
SELECT TOP 1 * FROM yourTable
WHERE PartNumber=DesiredPart# ORDER BY Price

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV shouldn't that be:

SELECT TOP 1 * FROM yourTable
WHERE PartNumber=DesiredPart# ORDER BY Price DESC
 
earthandfire, the OP want the LOWEST price.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top