View Full Version : summing field in query


Jeremy0028
09-19-2009, 10:44 AM
Need some help with the following attachment. As you can see i have 4 query fields named Fee, totalPayments, Total Adjustment and a field called balence.

What im focusing on is balence so lets say in the following example.

Fee =200.00
total Payments =150.00
Total Adjustments = 25.00
Balence would be the subtracting of 200-150-25

need some help in writing code in the balence field column so could subtract the above 3 columns

Any advice would be greatly appricated.

dcb
09-19-2009, 11:27 AM
Hi

Try this - I have summed [Fee]

SELECT tblCharges.ClaimID, Sum(tblCharges.Fee) AS SumOfFee, qrySumOfPayments.TotalPayments, qrySumOfPayments.TotalAdjustment, [Fee]-[TotalPayments]-[TotalAdjustment] AS Balance
FROM tblCharges LEFT JOIN qrySumOfPayments ON tblCharges.ClaimID = qrySumOfPayments.ClaimID
GROUP BY tblCharges.ClaimID, qrySumOfPayments.TotalPayments, qrySumOfPayments.TotalAdjustment, [Fee]-[TotalPayments]-[TotalAdjustment];Cheers
DCB

Jeremy0028
09-19-2009, 12:39 PM
where would i put tht in the query?

thankz

dcb
09-19-2009, 12:53 PM
You are using 2003
Instead of trying to modify what you have i suggest you just create a new query (mine may not work)
create new query -> cancel the add table dialog
You should now be in sql view - you can change views with the drop down box next to the view button
copy paste the query into sql view
Run

Tell me if it works....