SELECT * FROM [dbo].[Client] WHERE MdmId In (
SELECT DISTINCT C.MdmId
FROM [coordinator].[ServiceRequestGroupConfiguration] A
JOIN [coordinator].[ConfigurationClient] B ON A.[Id] = B.[ServiceRequestGroupConfigurationId] AND B.[Active] = 1
JOIN [dbo].[Client] C ON B.[ClientId] = C.[Id]
LEFT JOIN [threesixty].[MasterDataMapping] D ON D.[MappedId] = C.[MdmId] AND D.[MappedType] = 'Acosta Client' AND D.[IsActive] = 1 AND D.[EntityType] = 'Client'
WHERE A.[Active] = 1 AND D.[Id] IS NULL)