Name | City | Troops | Support |
A | XYZ | 10 | Y |
B | XYZ | 30 | N |
C | PQR | 20 | Y |
D | PQR | 40 | N |
E | MNO | 30 | Y |
F | MNO | 10 | N |
A | MNO | 20 | Y |
B | PQR | 40 | N |
C | XYZ | 25 | Y |
D | MNO | 35 | N |
E | PQR | 45 | Y |
F | XYZ | 5 | N |
A | PQR | 40 | Y |
B | XYZ | 25 | N |
C | MNO | 35 | Y |
D | PQR | 45 | N |
E | XYZ | 5 | Y |
F | MNO | 20 | N |
My dataset looks something like this with lot many rows. I want to find the sum of troops A has with Support (Support is Y) and for only XYZ and MNO Cities.
I have tried something like this
Case
when support = y then
case when city = MNO or city = XYZ then
troops
end
end
I use both or & and at the red colored portion above but I was not able to get the required number.
Please help me