Logic is not wokring

  • It's been a while since I've messed with negative boolean algebra so I hope I got this right...

    The first one equates to NOT (invoice_cl  =  'INN1' OR PaymentStatus = 'Unpaid').  That means that anything with an 'IIN1' will be excluded and anything with an 'Unpaid' in the rows will be excluded whether or not it's an 'IIN1' row or not.

    The second one states that both 'INN1' AND 'UnPaid' must be in the same row and, if they are, only then exclude it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • not (invoice_cl in('INN1') and [Payment Status] = 'Unpaid')
    = (invoice_cl not in('INN1') or [Payment Status] <> 'Unpaid')
    = (invoice_cl <> 'INN1' or [Payment Status] <> 'Unpaid')

    so the statement

    [Invoice Class] IN (@invoice) and not (invoice_cl in('INN1') and [Payment Status] = 'Unpaid')

    is equivalent to

    [Invoice Class] IN (@invoice) and (invoice_cl <> 'INN1' or [Payment Status] <> 'Unpaid')

    So in your first statement you have an AND where you should have an OR

  • Thank you  Jonathan AC Roberts and  Jeff Moden for replying back to me. your explanations were really helpful.:)

    • This reply was modified 4 years, 8 months ago by ajoe.

Viewing 3 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply