This mornings coffee break, I created this example using a Scripting Extension - once you have an understanding of this, we can then talk about how to gear it within an Automation Script (which will be a very similar exercise, with minor differences).
The key to this is using the Javascript reduce() method. I've also demonstrated how you can filter the data using a filter() method, before the data is summed via reduce().
const emailTable = base.getTable("Numbers Table");
let records = await emailTable.selectRecordsAsync({
fields: ["Fruit", "Total Mass"]
});
console.info(records);
let initialValue = 0;
let sumMass = records.records
.filter(
(record) =>
record.name !== "Green Apple"
)
.reduce((accumulator, record) => record.getCellValue("Total Mass") + accumulator, initialValue);
console.log(sumMass);
Here, we can see the data that's been filtered, then reduced - and the final total;