• Luis Cazares (9/17/2014)


    You should read the discussion on this article. Of course, you must change the conditions a little bit for "C".

    http://www.sqlservercentral.com/articles/T-SQL/88244/

    Thank you Luis - for the clue.

    Based on the article Find Customers Who Bought "A" and "B" But Not "C" (SQL Spackle)[/url]

    SELECT

    ID

    FROM dbo.Consumer

    WHERE Resource IN ('RG','MI')

    GROUP BY ID

    HAVING COUNT(DISTINCT Resource) =2

    EXCEPT

    -- Ignore all Resource except RG and MI

    SELECT ID

    FROM dbo.Consumer

    WHERE Resource NOT IN ('RG','MI');