Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Unanswered: Sum Columns then limit the output

    Hello All,

    I am trying to add two columns together and find all the entries that equal zero I have:

    select table1.nbr, table2.itemvalue as CC
    from table1, table2
    where table1.nbr=table2.nbr and exists (select (OpnAc1+OpnAc2) as Open from table2

    I want to take the sum of OpnAc1 and OpnAc2 and find all that equal 0, (meaning no open 1 or open 2)

    Thanks in advance for your help.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    SELECT *
    FROM   table2
    WHERE  OpnAc1 + OpnAc2 = 0
    ??
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    SELECT t1.nbr, t2.itemvalue
    FROM table1 t1 JOIN table2 t2 ON t1.nbr = t2.nbr
    GROUP BY t1.nbr, t2.itemvalue
    HAVING SUM(t2.OpenAc1)+SUM(OpnAc2) = 0

    ?????

    How about some sample data and expected results

    my usb esp port is clogged
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •