I need to embed a case statement inside of an AND statement.
Basically, if company1 is fed in, I want records that have an new_employeridname value of company1 or company2 in my results.
Otherwise (company3, company4, etc) I just want the records that directly match.
See last line below.
SELECT new_planname, new_benefitplanid, new_provider
FROM new_benefitplan WITH(NOLOCK)
WHERE new_planyear = @Year
AND new_inscope = 1
AND new_benefitplantype = 1
AND statuscode <> 2
AND CASE WHEN @EmployerIdName = 'Company1' THEN ( new_employeridname = @EmployerIdName OR new_employeridname = 'Company2')ELSE new_employeridname = @EmployerIdName END