Results 1 to 2 of 2
  1. #1
    g8rnc is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    2

    Sum Column with conditions

    Hopefully you guys can help me, I'll try to keep this as simple as possible while still being descriptive enough. Here's what I'm trying to accomplish:

    In Table1 I want to sum all the numbers from Column1 if they have the same number in Column2. For example, these would be added:
    Column1 Column2
    ----1----------5
    ----2----------5


    ----3----------5
    ----4----------4 (Not added)

    The sum in this example should be 6 (3+2+1).

    Also, I want to take this sum and place it in a field in Table2 that has the same number from Column2 (Table1) as Column2 (Table2). So in my previous example the sum that equals 6 would be put in Column2, Table2 under the entry for 5. The sum that equals 4 would be placed in Column2, Table2 under the entry for 4.

    Column2 in Table2 is the primary key, so there are no multiples for that.

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Calculated fields (sums) should not be put in a table; a query is preferrable:

    Code:
    SELECT Table1.Column2, Sum(Table1.Column1) AS SumOfColumn1
    FROM Table1
    GROUP BY Table1.Column2;
    Cheers,

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

Similar Threads

  1. iif statement with multiple conditions
    By ragsgold in forum Queries
    Replies: 7
    Last Post: 08-24-2011, 05:38 PM
  2. Replies: 1
    Last Post: 04-15-2010, 02:07 AM
  3. if...then conditions ???
    By em07189 in forum Access
    Replies: 6
    Last Post: 03-05-2010, 10:29 PM
  4. Conditions / Expressions
    By Mark344 in forum Access
    Replies: 1
    Last Post: 02-19-2010, 08:15 AM
  5. inserting values in column based another column
    By wasim_sono in forum Database Design
    Replies: 1
    Last Post: 06-27-2006, 05:23 AM

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