• Keith Tate (2/5/2014)


    First please read the article in my signature about posting these types of questions to the forum. After you do that I could make sure that the answer is correct. Without the necessary information the following where statement should get you what you want:where type not in ('aa', 'cc')

    and type <> = 'g2'

    and code = 3

    and (table2.start_date is null

    or table2.end_date is null

    or table2.program_id is null)

    Instead of all of the nulls you could use union all for each of the "is null" statements.

    Just a curiosity... why did you treat 'g2' separately instead of just using...

    WHERE [Type] NOT IN ('aa','cc','g2')

    --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)