MS SQL: Multiple columns are specified in an aggregated expression containing an outer reference.
Posted on 2006-11-10
In this small query:
SUM(CASE BMUT1.BMU_NAAR_BUD_ID WHEN B.BUD_ID THEN BMUT1.BMU_BEDRAG ELSE 0-BMUT1.BMU_BEDRAG END)
BMUT1.BMU_NAAR_BUD_ID = B.BUD_ID
BMUT1.BMU_VAN_BUD_ID = B.BUD_ID
BMUT1.BMU_EINDDATUM IS NULL
BMUT1.BMU_MPR_ID = B.BUD_MPR_ID
BMUT1.BMU_INITIEEL <> 0
B.BUD_EINDDATUM IS NULL;
MS SQL returns me the following error:
Msg 8124, Level 16, State 1, Line 1
Multiple columns are specified in an aggregated expression containing an outer reference. If an expression being aggregated contains an outer reference, then that outer reference must be the only column referenced in the expression.
This query is actually a small part of a much, much larger query I converted out of an MS Access project (here there's no problem) resulting in the same error. I narrowed it down to the query you see above to find the source off the problem ...
What am i overseeing ?? I'm looking at this little piece for 2 days now, and it's driving me crazy ... :P