christopher clark christopher clark - 6 months ago 29
SQL Question

Is there a way to ignore the AND in a CASE when something is true?

I have this


Select * From Student_Info si
Inner Join Certifications cc
Inner Join Cert_Earned ce

Where si.grad_date = @grad_date
AND cc.org_no = @org_no

but I need an additional
that should be ignored if it turns out the value is false, I will want ALL certificates

AND cc.industrial = CASE WHEN @industrial = 0 THEN Do Nothing
Else @industrial


This would normally be expressed as:

AND (@industrial = 0 OR ccc.industrial = @industrial)