Can't figure out the syntax for a where clause
I have开发者_如何学C a report that contains the following parameter "Fine > 0" and the choices are "Yes", "No" and both using a multi-select dropdown box. The parameter gets passed to the stored procedure as either "Yes', "No" or "Yes, No".
In the SP has syntax similar to this
Case WHEN @FineAmount = 'Yes' THEN I.Fine > 0
WHEN @FineAmount = 'No' Then I.Fine = 0
ELSE I.Fine >= 0
END
Here's some case logic that will get the job done.
where
I.Fine > case
when @FineAmount like '%Yes%' then 0
else I.Fine + 1 end
or I.Fine = case
when @FineAmount like '%No%' then 0
else I.Fine - 1 end
精彩评论