Hi, I have the following results: (Customer, Pet1 and Pet2 are the columns returned) Customer Pet1 Pet2 John Dog Cat John Dog What I need to show is only one row for this customer. Since John has a both a dog and a cat, I want to return only that row. But say he only had a dog and not a cat, then I would only want to return that row. Make sense? Thanks!
Select the "max" pet from each column and group by customer... WITH bob AS ( SELECT 'John' AS Customer, 'Cat' AS Pet1, NULL AS Pet2 UNION ALL SELECT 'John', 'Cat', 'Dog' ) SELECT Customer, MAX(Pet1) AS Pet1, MAX(Pet2) AS Pet2 FROM bob GROUP BY Customer