Add extra Sum table and under Name type Sum of Costs, so just one record in this table.
Now go to Cost table and add a field with link to the Sum table.
Link the first record to the one field.
Copy this to the other records.
In Sum table you add a Rollup field where you add up the costs from the Costs table.
Now in Costs table you add a Lookup field where you lookup the Rollup field from the Sum table.
The result is you get the sum of all Costs in every record. You can use this now for further calculation per record.