Tinashe - 4 months ago 13

SQL Question

I am trying to add two select statements with onyl negative values, these are the statements:

`SUM(CASE WHEN LinkAcc = '8420000' THEN amount < 0 END)`

SUM(CASE WHEN LinkAcc = '8400000' THEN amount < 0 END) AS Payments

I have tried :

`SUM(CASE WHEN LinkAcc = '8400000,8420000' THEN amount < 0 END) AS Payments`

Answer

`THEN amount < 0`

doesn't make much sense. If I understood you correctly, what you want is:

```
SUM(CASE
WHEN LinkAcc IN ('8420000','8400000') AND amount < 0
THEN amount
END) As Payments
```