I am doing a report whereby I can't construct the SQL programatically. I have two values that are fed into the report. The values that can be one of the following three options:
- redeem
- purchase
- redeem AND purchase
The query needs to have a WHERE clause. If "redeem" is fed in, it must have:
... WHERE balance < 0
If "purchase" is fed in, it must have:
... WHERE balance >= 0
if both are fed in, this condition can be left out completely, or it can be said:
... WHERE balance >= 0 OR balance < 0 --> but this is redundant
Is there a way to apply this kind of logic in SQL? Is something like this possible in SQL:
SELECT * FROM account WHERE (if param1 = 'redeem' then 'balance <= 0) ... etc
?
caseinwhere, this might be useful: stackoverflow.com/questions/6812276/…