Hi!Here is my table data:CREATE TABLE #TestTable ( Pk INT, GroupID INT, Enabled BIT )INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (1,1,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (3,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (4,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (5,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (6,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (7,2,0)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (8,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (9,2,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (10,3,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (11,3,1)INSERT INTO #TestTable (Pk, GroupID, Enabled) VALUES (12,3,1)SELECT * FROM #TestTableDROP TABLE #TestTable
I need to write a select query that will retrieve any GroupID in which every record has an Enabled value of 1.In the example I've provided, only GroupID 1 and 3 will be returned since GroupID 2 has a record with an Enabled value of 0.What would be the most efficient way to write such a query?I appreciate your help!