Link to home
Start Free TrialLog in
Avatar of isames
isames

asked on

SQL Query Subtract

i have two columns: Beginning Balance, Ending Balance.

I would like to sum each column and then subtract. the output would be the Actual.

or the query could probably just subtract the two columns without doing the sum.

Attached is the table
Accounting.png
Avatar of Qlemo
Qlemo
Flag of Germany image

And what is the issue? Just subtract the columns from each other.
Or do you want to have the aggregated balance for e.g. each companyID?
Avatar of isames
isames

ASKER

For now, just subtract the two columns.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Select CompanyID, Sum(d.theDifference)
From (Field1-Field2 AS theDifference
From TableNameYouHave) AS d
Group By CompanyID

Open in new window


Please replace Field1, Field2, TableNameYouHave as you have.

Mike
isames, do you still need help on this question?
Avatar of isames

ASKER

I believe I'm okay on this one.

Thank you