add values for different products and get their total amount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gerryis2000
    New Member
    • Jun 2010
    • 16

    #1

    add values for different products and get their total amount

    I would like to add values for different products and get the total value in Ma access.
    e.g

    PRODUCT_NAME UNIT_PRICE QUONTITY
    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?

    Thanks,

    Regards,
    Gerald.
  • mcupito
    Contributor
    • Aug 2013
    • 294

    #2
    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?

    Code:
    SELECT e.ProductName, e.UnitPrice,e.UnitQuontity,
    (SELECT 
     SUM(y.Quontity)
                    From YourTable AS y)  AS SumAmt
    FROM YourTable AS e

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      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.

      Comment

      • mcupito
        Contributor
        • Aug 2013
        • 294

        #4
        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.

        Comment

        Working...