Sum by Part Number

D

Deb

In my inventory table, I have multiple records with the same part number and
sometimes the same part with have a different cost. I need to sum all of the
records for each part number and unit cost. I thought the code below would
work, but it isn't doing the job.

SELECT DISTINCTROW sqry_ViewInventory.PartNo, sqry_ViewInventory.UnitCost,
Sum(sqry_ViewInventory.[Quantity On Hand]) AS [Sum Of Quantity On Hand]
FROM tbl_InventoryListing
GROUP BY sqry_ViewInventory.PartNo, sqry_ViewInventory.UnitCost;

Thanks in advance!
 
K

KARL DEWEY

but it isn't doing the job.
What ain't it doing or doing it should not?

Maybe dropping out the UnitCost and DISTINCTROW would do it for you.
SELECT sqry_ViewInventory.PartNo, Sum(sqry_ViewInventory.[Quantity On
Hand]) AS [Sum Of Quantity On Hand]
FROM tbl_InventoryListing
GROUP BY sqry_ViewInventory.PartNo;
 
D

Deb

I'm developing a form, selecting the part number from a combo box. The
client may have over 200 of any given part. The parts are listed in a
subform based on the selection from the combo box. I want to display the
total quantity of the selected part by adding the quantity in stock from the
various records together in a box on the form. I've decided to just display
the cost in the subform to keep things simpler.

KARL DEWEY said:
What ain't it doing or doing it should not?

Maybe dropping out the UnitCost and DISTINCTROW would do it for you.
SELECT sqry_ViewInventory.PartNo, Sum(sqry_ViewInventory.[Quantity On
Hand]) AS [Sum Of Quantity On Hand]
FROM tbl_InventoryListing
GROUP BY sqry_ViewInventory.PartNo;
 
K

KARL DEWEY

Is it working for you now or do you need more assistance?
--
Build a little, test a little.


Deb said:
I'm developing a form, selecting the part number from a combo box. The
client may have over 200 of any given part. The parts are listed in a
subform based on the selection from the combo box. I want to display the
total quantity of the selected part by adding the quantity in stock from the
various records together in a box on the form. I've decided to just display
the cost in the subform to keep things simpler.

KARL DEWEY said:
but it isn't doing the job.
What ain't it doing or doing it should not?

Maybe dropping out the UnitCost and DISTINCTROW would do it for you.
SELECT sqry_ViewInventory.PartNo, Sum(sqry_ViewInventory.[Quantity On
Hand]) AS [Sum Of Quantity On Hand]
FROM tbl_InventoryListing
GROUP BY sqry_ViewInventory.PartNo;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top