Hi all
Im not sure whtehr this is possible or not? I have this query as follow:
SELECT DISTINCT 'EXISTING_CASE' AS CaseType, cs.CaseID
FROM cms_Cases cs INNER JOIN cms_CaseClientProfiles ccp ON cs.CaseID = ccp.CaseID
INNER JOIN cms_ClientProfiles cp ON ccp.ClientProfileID = cp.ClientProfileID
INNER JOIN cms_Clients cl ON cp.ClientID = cl.ClientID
INNER JOIN cms_ClientTypes ct ON ccp.ClientTypeID = ct.ClientTypeID
INNER JOIN cms_CaseServices css ON cs.CaseID = css.CaseID
INNER JOIN cms_Services srv ON css.ServiceID = srv.ServiceID
WHERE ct.ClientTypeCode = 'CLT-0-PRIMARY'
AND cs.AssignmentUTCDate < @UTCStartPeriod AND (cs.ClosedCaseUTCDate >= @UTCStartPeriod OR cs.ClosedCaseUTCDate IS NULL)
AND srv.ServiceCode = 'SRV-1-FND-RGF'
AND srv.ParentServiceID = @ServiceID
AND cs.TenantID = @TenantID
AND ccp.TenantID = @TenantID
AND cl.TenantID = @TenantID
AND ct.TenantID = @TenantID
I want to in the CASS statement in WHERE statement so IF let say the @ServiceID = 0 ... I don't want the "AND srv.ParentServiceID = @ServiceID" this line is running.
I can probably construc the sqlstatment and running using EXEC but if I can avoid that will be goood.
Thanks