christopher clark christopher clark - 1 year ago 60
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

Answer Source

This would normally be expressed as:

AND (@industrial = 0 OR ccc.industrial = @industrial)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download