What is your expected output and or is the query you provided correct? I might be reading your requirement incorrectly, but I thought you wanted to know all the Items that have been Received and Processed but not approved. Is that correct or am I off?Assuming that I'm right, here is one way to do it:DECLARE @ProdHis TABLE (Item CHAR(1), Time DATETIME, Code INT, Status VARCHAR(50))INSERT @ProdHisSELECT 'A', '05/15/2009 00:00:00', 100, 'Received'UNION ALL SELECT 'A', '05/15/2009 00:01:00', 110, 'Processed' UNION ALL SELECT 'A', '05/15/2009 00:02:00', 120, 'Approved'UNION ALL SELECT 'B', '05/15/2009 00:03:00', 130, 'Relocated' UNION ALL SELECT 'B', '05/15/2009 00:04:00', 140, 'Send complete' UNION ALL SELECT 'C', '05/15/2009 00:05:00', 110, 'Received' UNION ALL SELECT 'C', '05/15/2009 00:06:00', 110, 'Processed' SELECT ItemFROM @ProdHisWHERE Code IN (100, 110, 120) AND time BETWEEN '2009-05-15 00:00:00' and '2009-05-16 00:00:00'GROUP BY ItemHAVING COUNT(*) = 2
EDIT: Forgot Time restriction.