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

Finding Minimums and maximums on many fields

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
I have a table that lists customers, orders dates, quantities, etc.
i need to write a query that will find the mins and maximums for each customer. Unfortunately, sometimes the quantity is 0. I need to eliminate the o's and find the minimum ordered.

My table looks like:
Cust_No Part Quantity
1 25 10
1 25 0
1 25 30
2 25 10
2 25 0
3 25 10
3 25 0
3 25 40
3 25 0

Any help will be definitely appreciated!
Bill
 
Select Cust_No , Part , min(Quantity) as least ,
Max(Quantity) as most
from tablename
where >0
group by Cust_No , Part
 
I'm Sorry. I need to add to the table above. It looks more like:
My table looks like:
Cust_No Part_25_Quantity Part_10_quantity
1 10 14
1 0 25
1 30 0
2 10 35
2 0 14
3 10 18
3 0 17
3 40 25
3 0 25

Each record is 1 order. Sometimes the order is for all parts and sometimes only 1. The result needs to look like:
Cust_No Part_25_Min Part_10_Min Part_25_Max Part_10_Max
1 10 14 30 25
2 10 14 10 35
3 10 17 40 25

Sorry for the confusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top