SQL Query to remove itself with result found others.

WeTi
WeTi used Ask the Experts™
on
Dear expert

I got problem with a query.

  SELECT ID
  FROM [system_Prod].[System].[Approvement]
  where ApprovementStatusId = 7

Open in new window

This will show approvementStatusId = 7. Problem is next one query, I want all result ID that show up, all the duplex removes include the ID that got duplex it self for exemple: ID: 5000, with ApprovementStatusid = 7 shows up, and ID 5000 got also  ApprovementStatusID = 4, if it detect this, it will remove ID 5000 completely from the result. Is this possible to do?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior .Net Consultant
Top Expert 2016
Commented:
you can try something like this:

  SELECT ID
  FROM [system_Prod].[System].[Approvement]
  where ApprovementStatusId = 7
and ID not in (select ID   FROM [system_Prod].[System].[Approvement]  where ApprovementStatusId = 4)

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial