I have been trying to put an OR operator in CASE expression but it doesn't work.
WHERE W.Organization_ID =
CASE @IsAdmin OR @IsChiefEngineer
WHEN 1
THEN W.Organization_ID
ELSE @OrganizationID END
I want to check if any IsAdmin or IsChief engineer, either or they is 1 then Organization else @OrganizationID
Nearly, just alter your case expression a bit:
CASE
WHEN @IsAdmin = 1 OR @IsChiefEngineer = 1
THEN W.Organization_ID
ELSE @OrganizationID
END
You can write it as follows:
Where W.Organization_ID = CASE
WHEN @IsAdmin = 1 OR @IsChiefEngineer = 1
THEN W.Organization_ID
ELSE @OrganizationID END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With