Results 1 to 3 of 3
  1. #1
    jrvf is offline Novice
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    1

    Partial SUM of values on a query.

    Hi there,

    Imagine we have a table like:


    ID ValueA
    1 20


    2 35
    3 23
    4 42
    5 61
    6 32
    7 40


    And we want to query that table with new column containg the partial sum of the valuesA listed.

    Let me give you some examples:

    1 - list table where ID are even:


    ID ValueA SUM
    2 35 35
    4 42 77
    6 32 109


    2 - list table where ID are odd:


    ID ValueA SUM
    1 20 20
    3 23 43
    5 61 104
    7 40 144


    3 - list table where valueA is less than 41:


    ID ValueA SUM
    1 20 20
    2 35 55
    3 23 78
    6 32 110
    7 40 150


    Is there anyway we can do that?
    Does anyone know the SQL declaration that allow us to do that?

    Thank you for all your support.

  2. #2
    ryan1313 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    20
    It looks like you want to do a running total on those values. Here is a "how to" from microsoft on setting that up.

    http://support.microsoft.com/kb/290136

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    if you want one kind at one query, that is simple.
    following query is for several sums at one query:

    SELECT Sum(IIf((ID Mod 2)=0,ValueA,0)) AS SumEven, Sum(IIf((ID Mod 2)=1,ValueA,0)) AS SumOdd, Sum(IIf(ID<41,ValueA,0)) AS SumLess41
    FROM YourTable;

Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIf using other field values in same query
    By ErikaMarie0421 in forum Queries
    Replies: 2
    Last Post: 08-03-2010, 12:21 PM
  2. Replies: 1
    Last Post: 03-22-2010, 03:37 PM
  3. Replies: 2
    Last Post: 02-22-2010, 04:19 PM
  4. Query help for WTD and MTD values.
    By rzawora in forum Queries
    Replies: 1
    Last Post: 10-26-2009, 04:30 AM
  5. Partial Matching based Queries
    By Yatesb in forum Queries
    Replies: 0
    Last Post: 02-23-2009, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums