SELECT dbo.Systems.SiteNumber, Derived_Policy_Audit_Latest.PolicyID, dbo.PolicyAudit.ProductCode, dbo.PolicyAudit.LobFROM dbo.RejectReason RIGHT OUTER JOIN dbo.PolicyAudit ON (dbo.RejectReason.PolicyAuditID=dbo.PolicyAudit.ID) LEFT OUTER JOIN dbo.Systems ON (dbo.PolicyAudit.SourceSystemID=dbo.Systems.ID) INNER JOIN(select dbo.PolicyAudit.policyid as policyid, dbo.PolicyAudit.SourceSystemID as SourceSystemID, dbo.Systems.SiteNumber as SiteNumber , MAX(dbo.PolicyAudit.LastModifiedDate) as Recdate from dbo.PolicyAudit INNER JOIN dbo.Systems ON (dbo.PolicyAudit.SourceSystemID=dbo.Systems.ID) group by policyid , SourceSystemID,dbo.Systems.SiteNumber ) Derived_Policy_Audit_Latest ON (dbo.PolicyAudit.PolicyID=Derived_Policy_Audit_Latest.policyid and dbo.PolicyAudit.LastModifiedDate = Derived_Policy_Audit_Latest.Recdate and dbo.PolicyAudit.SourceSystemID=Derived_Policy_Audit_Latest.SourceSystemID and Derived_Policy_Audit_Latest.SiteNumber= dbo.Systems.SiteNumber) WHERE ( dbo.PolicyAudit.Status IN ( 2 ) AND dbo.PolicyAudit.IsCurrent IN ( 1 ) AND ) order by 1Now i need to include if dbo.Systems.SiteNumber=C1 then it should check and restrict for the below conditiosn1. dbo.PolicyAudit.productcode ='123' and dbo.PolicyAudit.lob IN ('123')or 2 .dbo.PolicyAudit.productcode ='127' and dbo.PolicyAudit.lob IN ('54')etc and it goes of with another 5 similar conditions . How can i incorporte in the where clause to restirct this
↧