By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

add values for different products and get their total amount

P: 16
I would like to add values for different products and get the total value in Ma access.

Fanta 100 10
Cock 80 5
Pepsi 70 15

Now How do i get total for the three comodities and represent the expression in a field in ms access querry or form?


Feb 28 '14 #1
Share this Question
Share on Google+
3 Replies

P: 294
If you're trying to get a sum of a specific field, it would be something like this (for "Quontity") but are just trying to Sum each row?

Expand|Select|Wrap|Line Numbers
  2. SELECT e.ProductName, e.UnitPrice,e.UnitQuontity,
  3. (SELECT 
  4.  SUM(y.Quontity)
  5.                 From YourTable AS y)  AS SumAmt
  6. FROM YourTable AS e
Feb 28 '14 #2

Expert Mod 15k+
P: 31,769
The SQL subquery approach illustrated by Mark is an answer for getting the value into a query when you also want to see all the determining records. If only the total is required then a simpler aggregate query is all that's required (No subquery).

In a form or report though, you can total using the Sum() function. This is possible anywhere, but is usually handled in the Form or Report footer sections.
Mar 1 '14 #3

P: 294
Thanks for clearing that up for me, NeoPa. I wish the OPs would return often enough and provide more clarity or let us know if our solution worked xP.
Mar 2 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.