Results 1 to 4 of 4
  1. #1
    Thoudus is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    2

    Lightbulb SUM Multiple fields in a query

    Hi all,

    First of all sorry if this has already been adressed elsewhere.



    I'm a begginer in access.

    I have a query with multiple fields that I want to sum based on criteria. For example, I want to sum 10 fields but only if the value is "1". Then I want to sum the same fields but only if the value is "2"...

    Can anybody help me?

    Thank you

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    SELECT SUM(*)
    FROM Table1
    WHERE Field1 = '1'
    OR
    WHERE * = '1'

    Think you can use * in a where clause, if not name the table 'AS a', then use a.*.
    Is that what you want?

    Good Luck.

    Rixxe

  3. #3
    Thoudus is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    2
    Thank you Rixxe,

    But besides Field1, the other fields also have to be = 1. Otherwise I want to discard them from the SUM.

    Am I missing something?

    Sorry if I'm messing up

  4. #4
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    Sorry should have mentioned:

    If you want to add the criteria to ALL fields (So all fields = 1)
    Then this is the best bet:

    SELECT SUM(*)
    FROM Table1 AS a
    WHERE a.* = '1'

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

Similar Threads

  1. Update Multiple fields according multiple criterias
    By denis.m in forum Programming
    Replies: 1
    Last Post: 02-21-2011, 11:03 AM
  2. Replies: 4
    Last Post: 09-22-2010, 01:47 AM
  3. Replies: 1
    Last Post: 06-28-2010, 11:04 PM
  4. Replies: 1
    Last Post: 02-03-2010, 09:17 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 PM

Tags for this Thread

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