Given your sample data and expected result set, this works:CREATE TABLE YourTable(Batch int, [Sample] int, Value char(1))INSERT INTO YourTableSELECT 0, 0, 'A' UNION ALLSELECT 0, 1, 'A' UNION ALLSELECT 1, 0, 'A' UNION ALLSELECT 1, 1, 'B' UNION ALLSELECT 2, 0, 'B' UNION ALLSELECT 2, 1, 'B'SELECT Batch, Differnt = CASE WHEN COUNT(Batch) = 1 THEN 'FALSE' ELSE 'TRUE' ENDFROM( SELECT DISTINCT Batch, Value FROM YourTable) tGROUP BY BatchDROP TABLE YourTable
Tara Kizeraka tduggan