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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct Lowest Query 1

Status
Not open for further replies.

marcoman44

IS-IT--Management
Dec 22, 2003
62
0
0
US
I have multiple item names with multiple costs. How do I write a query that will take the lowest cost associated by item name.

For example

Item A 56.34
Item A 34.65
Item B 78.93
Item B 67.45


I want the folowing results:

Item A 34.65
Item B 67.45

Any help is appreciated.
 
SELECT Item, Min(Cost) AS LowerCost
FROM yourTable
GROUP BY Item;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
SELECT t1.item, t1.cost From mytable t1 WHERE t1.cost IN ( SELECT TOP 1 cost From mytable t2 WHERE t1.item=t2.item ORDER BY t2cost ASC)

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top