[Resolved] "Quantity" Count Help in SQL Expression
I'm developing an inventory application. There is a column "Product Name" and a column "Quantity". I wish to group the same product name together to produce a quantity.
What I mean is:
Product_Name
Coke
Coke
Coke
Total of coke is: 3
So I have these expression currently : SELECT Product_Name, SUM ('Inventory'.i duno how 2 continue) FROM 'Inventory' GROUP BY Product_Name
What i wish to do is the statement will group similar product_name's names together and count how many records are repetitve by the similar names.
Thanks in advance.
Re: "Quantity" Count Help in SQL Expression
I think this should do the trick for you.
Code:
"SELECT SUM(YourTable!Quantity) FROM YourTableName WHERE [Product Name] = 'coke'"
Re: "Quantity" Count Help in SQL Expression
Lintz's method is fine if you are looking for a specific product, but not for multiple products. If that is what you want then one of these will probably do what you want:
If you want a total of the "Quantity" field per unique value in "Product_Name" then use this:
Code:
SELECT Product_Name, SUM (Quantity)
FROM 'Inventory'
GROUP BY Product_Name
If you just want to return the number of rows containing each Product_Name then use this:
Code:
SELECT Product_Name, count(Product_Name)
FROM 'Inventory'
GROUP BY Product_Name
Re: "Quantity" Count Help in SQL Expression
:) Ok thanks. It is resolved. I used the 2nd method and it works.