drew.allen (10/15/2012)
I think that a GROUP BY is much simpler and probably faster, too.
With YOURTABLE (TICKET,STATUS)
AS
(
SELECT 9543,1 UNION ALL
SELECT 9543,5 UNION ALL
SELECT 9543,5 UNION ALL
SELECT 9544,1 UNION ALL
SELECT 9546,1 UNION ALL
SELECT 9547,1 UNION ALL
SELECT 9547,5
)
SELECT TICKET, MAX(STATUS) AS STATUS
FROM YOURTABLE
GROUP BY TICKET
HAVING MAX(STATUS) = 1
GO
Drew
Oh, be careful. For this particular data, that will absolutely work. If they introduce status less than 5 that aren't cause for rejection, it won't.
--Jeff Moden
Change is inevitable... Change for the better is not.