subtraction in query?

erxefera

New member
Local time
Today, 03:06
Joined
Dec 2, 2005
Messages
9
Hi !
I have big problem in putting subtract function in sql query
i have 2 tables
In the first table i make "sum of amount" in each "category_name". In the second table i have 2 columns with the "category_name" and "available_amount".
I make query with join on "category_name" and i want to get like this:
"category_name", "sum of amount", "available_amount","available_amount"-"sum of amount"
I've tried to use "sum of amount" AS a1, "available_amount"-"sum of amount" AS a2 GROUP BY a2

I get "null as boolean in statement" or "column not found a1" errors....

Can anyone help me with this?
Thanks in advance!
i have to make this in a query.
 
In the first table i make "sum of amount" in each "category_name".
Do you mean this is a totals query rather than a table?
In the second table i have 2 columns with the "category_name" and "available_amount".
I make query with join on "category_name" and i want to get like this:
"category_name", "sum of amount", "available_amount","available_amount"-"sum of amount"
OK, assuming you're joining your totals query and the table in a new query.
I've tried to use "sum of amount" AS a1, "available_amount"-"sum of amount" AS a2 GROUP BY a2
Try this
Code:
[sum of amount], [available_amount]-[sum of amount] AS a2
I don't see why you want a Group BY clause here.
 

Users who are viewing this thread

Back
Top Bottom