Hi,Here is some sample data: CREATE TABLE #MyTable ( Pk INT, GroupID INT, Value VARCHAR(10) )INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (1,1,NULL)INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (2,1,'')INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (3,1,'ABC')INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (4,2,'')INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (5,2,'XYZ')INSERT INTO #MyTable (Pk, GroupID, Value) VALUES (6,3,NULL)SELECT * FROM #MyTableDROP TABLE #MyTable
I am looking to retrieve any GroupID in which every Value of that GroupID is either (a) null, (b) an empty string, or (c) "XYZ". So in the above example, GroupID #1 would not be returned in my query because there is a Value of "ABC", but GroupID #2 would be returned since it consists of only nulls, "XYZ"'s, and empty strings.What would be the most efficient way to write such a query?I greatly appreciate any assistance!