• Welcome to SQL Server Central. When posting, it's always helpful to provide DDL's and INSERT statement for your tables and data, rather than a copy and paste. Have a look at the link to Jeff's post in my Signature, but you can see how I would have done it for your question below.

    This should, however, get you what you're looking for:

    CREATE TABLE #MasterList (ID INT,

    Cat CHAR,

    [Status] VARCHAR(15));

    INSERT INTO #MasterList

    VALUES (101, 'X', 'Ready'),

    (102, 'X', 'Ready'),

    (103, 'Y', 'Dispatched'),

    (104, 'X', 'Dispatched'),

    (105, 'Y', 'Dispatched'),

    (106, 'X', 'Ready'),

    (107, 'X', 'Dispatched'),

    (108, 'Y', 'Ready'),

    (109, 'X', 'Dispatched'),

    (110, 'Y', 'Dispatched'),

    (111, 'X', 'Ready'),

    (112, 'X', 'Dispatched'),

    (113, 'X', 'Dispatched');

    CREATE TABLE #ListX (ID INT);

    INSERT INTO #ListX

    VALUES (101),

    (102),

    (106),

    (109),

    (112);

    CREATE TABLE #ListY (ID INT);

    INSERT INTO #ListY

    VALUES (105),

    (110);

    SELECT ML.ID,

    ML.Cat,

    ML.[Status]

    FROM #MasterList ML

    LEFT JOIN #ListX X ON ML.ID = X.ID AND ML.Cat = 'X'

    LEFT JOIN #ListY Y ON ML.ID = Y.ID AND ML.Cat = 'Y'

    WHERE X.ID IS NULL

    AND Y.ID IS NULL

    ORDER BY ML.ID;

    DROP TABLE #MasterList;

    DROP TABLE #ListX;

    DROP TABLE #ListY;

    Edit: Icky alignment!!!

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk