Brother Arnold
Member
- Local time
- Today, 23:51
- Joined
- Apr 28, 2022
- Messages
- 39
Hi,
I've spent far too long trying to get this to work and googling on line for an answer so it's your turn if you will to confirm why I'm feeling stupid at this moment and put me out of my misery.
So, in my inexperienced Access mind the following statement looks pretty simple and should work but it doesn't:
The total_paid comes back as 0 but it should be £280. Payment_type is not mandatory and in a lot of cases is often left blank. Client 100 has null payment_type in all its payment records but if I change the payment_type in one of the records to 'Cash' for example then the payment_amount for that record is included in the sum.
So the solution seems to be the following statement:
Is that right? Can anyone explain why null values cause this issue please?
I've spent far too long trying to get this to work and googling on line for an answer so it's your turn if you will to confirm why I'm feeling stupid at this moment and put me out of my misery.
So, in my inexperienced Access mind the following statement looks pretty simple and should work but it doesn't:
Code:
SELECT sum(payment_amount) AS total_paid
FROM tblPayment
WHERE (payment_type<>'Voluntary Contribution' AND client_ID=100);
The total_paid comes back as 0 but it should be £280. Payment_type is not mandatory and in a lot of cases is often left blank. Client 100 has null payment_type in all its payment records but if I change the payment_type in one of the records to 'Cash' for example then the payment_amount for that record is included in the sum.
So the solution seems to be the following statement:
Code:
SELECT sum(payment_amount) AS total_paid
FROM tblPayment
WHERE (payment_type<>'Voluntary Contribution' OR (ISNULL(payment_type))) AND client_ID=100
Is that right? Can anyone explain why null values cause this issue please?