Avatar of Douglas Cummings
Douglas Cummings

asked on 

Each group by expression must contain at least one column that is not an outer reference

I have an append query that generates the following error message:

ODBC--call failed.
[Microsoft][ODBC SQL Server Driver][SQL Server] Each group by expression must contain at least one column that is not an outer reference. (#164)

I am sure that this query worked at one time, but now I am getting the error message.

Does anyone have an idea how I can get around this problem?
INSERT INTO tblTempPSPHeader ( PSPReferralId, CheckAmount, CheckDate )
SELECT tblTempPSPDetail.PSPReferralId, Sum(tblTempPSPDetail.AmountToPay) AS SumOfAmountToPay, Date() AS Expr1
FROM tblTempPSPDetail
GROUP BY tblTempPSPDetail.PSPReferralId, Date();

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
Douglas Cummings
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Does this run on it's own and return the correct daytaset:

SELECT tblTempPSPDetail.PSPReferralId, Sum(tblTempPSPDetail.AmountToPay) AS SumOfAmountToPay, Date() AS Expr1
FROM tblTempPSPDetail
GROUP BY tblTempPSPDetail.PSPReferralId, Date();
Avatar of Douglas Cummings
Douglas Cummings

ASKER

Thanks for the help! Worked kike a charm. It was today's date that I wanted to insert into the CheckDate field.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Glad to help out!

You mentioned that this had worked for you in the past.  Just curious - Have you made a switch from Access to SQL for your back end?

To my knowledge, your syntax would have worked for you previously if you had been using an Access back end.
Avatar of Douglas Cummings

ASKER

Originally the temporary tables were local. But, due to other factors, I had to use a SQL database instead. That is when the problem developed.

Thanks again.
Avatar of Douglas Cummings

ASKER

I actually resolved the issue on my own, but not quite as elegantly as you. I figured it was the Date() expression and I simply deleted it from the query and added the date to the records via an update query. I like your solution better as it saved me a step.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo