Results 1 to 2 of 2

Thread: Need Expert Query Help

  1. #1
    Join Date
    Sep 2012
    Posts
    1

    Smile Need Expert Query Help

    I need helping writing a query that I have had to write anything like before.

    I have a table where I have to loop through the records and write out values where certain conditions are missing.

    I am comparing the value of 2 fields in TableA with the Values of 2 Fields in TableB. IF there is a record in TableA that does not have both fields match to TableB then write out a row

    Example below

    TableA
    Fields= AccountNumber,Month,Year

    TableB
    Field = Month,Year

    if there is a record in TableA where TableA.Month <> TableB.Month AND TableA.Year<>TableB.Year then write out the TableA.AccountNumber

    I thought this would be simple, but I am not getting the results I am looking for. Any experts out there to help would be greatly appreciated as I am new to learning about complex query writing.

    Thanks so much

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You will have to join tables on AccountNumber and compare the two conditions on Month,Year.

    select * from a
    join b
    on a.accountnumber=b.accountnumber
    where A.Month <> B.Month AND A.Year<>B.Year

Posting Permissions

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