• Try this...

    SELECT DISTINCT sttckt, stdescr

    FROM @Input t1

    WHERE stdescr <> 'freight'

    AND EXISTS (SELECT 1 FROM @Input t2 WHERE t2.sttckt = t1.sttckt AND t2.stdescr = 'Freight')

    Good Luck 🙂 .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.

    Good Luck 🙂 .. Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.