I am trying to do something like this in a CASE WHEN in my query but it is not taking the AND part, it says its an error in the syntax, it would not take && either. I would appreciate any help as I am not to much of a SQL guru..
Total =
CASE Payment.ID
WHEN 1 THEN mytable.Total
WHEN 4 AND trans.Amount IS NULL THEN mytable.Total
WHEN 4 AND trans.Amount IS NOT NULL THEN mytable.Total - trans.Amount
ELSE '0'
END,
Here is one way to do it. Change the expression to something like this.
Script:
There are two types of CASE expression namely
SimpleandSearched. You cannot combine Simple and Searched in the same expression.Simple:
Searched –
Example 1: In the simplest form.Searched –
Example 2: Involving multiple columns. You can add multiple columns in each of the WHEN statements.