Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to resolve error 3122 1

Status
Not open for further replies.

R00K

Technical User
Dec 8, 2003
79
CA
I am getting this error:

You tried to execute a query that does not include the specified expression "BalanceDate" as part of an aggregate function. (Error 3122)

On this code:

SELECT RunningBalance.BalanceDate, Sum(Nz(Transactions!Deposit,0)-Nz(Transactions!Withdrawal,0)) AS DepWith
FROM RunningBalance LEFT JOIN Transactions ON RunningBalance.BalanceDate = Transactions.TransDate
ORDER BY RunningBalance.BalanceDate;

I looked around and found that adding an "Order By" expression usually rolved the error. I already have it. Removing "Sum" resolves the error, but I have 2 depostis on one day that I want summed so that each date appears only once.

Thank you.
 
Hi!

Instead of, or along with, Order By, use Group By:

SELECT RunningBalance.BalanceDate, Sum(Nz(Transactions!Deposit,0)-Nz(Transactions!Withdrawal,0)) AS DepWith
FROM RunningBalance LEFT JOIN Transactions ON RunningBalance.BalanceDate = Transactions.TransDate
Group By RunningBalance.BalanceDate;
ORDER BY RunningBalance.BalanceDate;


hth


Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top