Collection membership rule to check for clients that are members of multiple AD groups

The following collection query will list all clients that are part of the following AD groups: "APP-1" and "APP-2". 

 
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.ResourceId in (Select ResourceID from SMS_R_System where SMS_R_System.SystemGroupName LIKE "%\\APP-1") and SMS_R_System.ResourceId in (Select ResourceID from SMS_R_System where SMS_R_System.SystemGroupName LIKE "%\\APP-2")


The following query does the same and also excludes all members of the "APP-1 Pilot" group.

 

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.ResourceId in (Select ResourceID from SMS_R_System where SMS_R_System.SystemGroupName LIKE "%\\APP-1") and SMS_R_System.ResourceId in (Select ResourceID from SMS_R_System where SMS_R_System.SystemGroupName LIKE "%\\APP-2") and SMS_R_System.ResourceId not in (select SMS_R_System.ResourceId from  SMS_R_System where SMS_R_System.SystemGroupName LIKE '%\\APP-1 Pilot')