I'm sorry if this has already been asked, but I have not found it already answered entirely yet - so I'm hoping someone can help provide some clarification.
I have a delete query in access that I only want to delete certain rows based on if they sum to 0
Ex:
Tom -1
Jill 5
John -3
Tom 2
Jill -3
John 3
I only want to delete John's records because they sum to 0. I want to keep Tom and Jill's records.
I have the delete where exists written -- and it is good about not deleting if none sum to 0, but if even one person sums to 0 it's trying to delete all the records. How can I get it to delete only the ones that sum to 0? Any help would be greatly appreciated.
Here is what I have:
DELETE *
FROM File
WHERE EXISTS
(SELECT sum(File.amount) as sum, File.name
FROM File
GROUP BY File.name
HAVING (((sum(File.amount))=0)))