SQL sum statement help

hooks

Registered User.
Local time
Yesterday, 22:34
Joined
Aug 13, 2004
Messages
160
I am wanting to sum up all deposits and all withdraws and get a balance. I have been unable to figure this out.

Here is my sql statement

Code:
sql = "SELECT Sum([DepositAmount])-Sum([PaymentAmount]) AS Balance " & _
                "FROM(tCTransactions)" & _
                "GROUP BY tCTransactions.AccountName " & _
                "HAVING((tCTransactions.AccountName) = 1)"


This works fine when using access but if i use my .net program then i get the "No value given for one or more required parameters." error

What i am wanting returned is the balance only. no other fields.

thanks a bunch

Hooks
 
Hi there

I would suggest removing the brackets around the table name in the from clause
 
OK Here is my sql statement

SELECT Sum(DepositAmount)-Sum(PaymentAmount) AS Balance " & _
"FROM tCTransactions " & _
"WHERE tCTransactions.AccountName = 1

Im still getting the same error
 
Last edited:
Hi

Can you show all your code, including ado command object as i am wondering if you have a paramater specified there.

failing that I am at a loss
 
Sorry for not replying. I ended up working around the problem

As always thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom