• iit depends on your data, if any status other than OK, then it fails, for example?

    With MyCTE (Product,Parts,Status)

    AS

    (

    SELECT 'Laptop1','mouse','OK' UNION ALL

    SELECT 'Laptop1','screen','OK' UNION ALL

    SELECT 'Laptop1','button','OK' UNION ALL

    SELECT 'Laptop2','mouse','OK' UNION ALL

    SELECT 'Laptop2','screen','OK' UNION ALL

    SELECT 'Laptop2','button','NOT OK'

    )

    select T1.Product, CASE

    WHEN T2.Product IS NOT NULL

    THEN 'Failed'

    ELSE 'OK'

    END

    FROM MyCTE T1

    LEFT OUTER JOIN (SELECT Product FROM MyCTE WHere Status <> 'OK') T2

    ON T1.Product = T2.Product

    GROUP BY T1.Product,T2.Product

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!