just wasted a long time figuring out this and I figure if I post it
might save someone some pain!
Jet (DAO) will allow you to to use nested aggregate functions like
building blocks, e.g.:
SELECT
A,
sum(B) as Answer1,
Answer1 * 2 as DoubleAnswer
From
Table
GROUP ON
A;
If you save this query and run it from ADO
(e.g. ADORecordset.Open "qrySavedQuery", myConnection) you will get:
You tried to execute a query that does not include the specified
expression 'Answer1 * 2' as part of an aggregate function.
Yet opening the saved query normally or calling it from DAO will work
fine.
ADO requires you to write the query like this:
SELECT
A,
sum(B) as Answer1,
sum(B) * 2 as DoubleAnswer
From
Table
GROUP ON
A;
i.e. an aggregate function cannot refer to another aggregate function
in the same query.
Anyone else found this, or am I mis-reading cause and effect of problem
here?