I 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 BY
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 BY
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? 5 6000
Hello BillCo,
You have to change the group by in ADO to:
GROUP BY
A,
Answer1 * 2 as DoubleAnswer
Regards,
Bas
I 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 BY
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 BY
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?
I tried that, as it seemed the obvious answer - and no joy... same
failure notice. the only thing that worked was to not use compound
aggregates; to break down the formula to field level. (Or to use a
subquery)
bas wrote:
Hello BillCo,
You have to change the group by in ADO to:
GROUP BY
A,
Answer1 * 2 as DoubleAnswer
Regards,
Bas
I 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 BY
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 BY
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?
BillCo wrote:
I 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 BY
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 BY
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?
Are you comparing apples to apples and oranges to oranges?
Did you try running the query in both ADO and DAO as a saved query?
Did you try running the query in both ADO and DAO as a query string?
When I test stored queries against stored queries I get the same
result: success.
When I test query strings against query strings I get the same results:
the error you describe.
Lyle,
the query was always saved as a standard jet mdb query (a2k)
it always ran fine from the ms access user interface.
However
dim rst as adodb.recordset
rst.open "qryCompoundAggregate", cnCurrentConnection
yields the error I reported.
I presumed (perhaps wrongly) that it was down to a difference in how
ADO handles the query's SQL syntax as opposed to Jet. Here's where I'm
hazy though - does ADO read the saved SQL and do it's own data-mining,
or does Jet serve the data regardless of what data language is used?
the fact that saved queries with * wildcards are rejected by ADO would
suggest the former.
I havent tested with a DAO recordset. So you are probably correct -
apples and oranges. I'll check it out.
Are you comparing apples to apples and oranges to oranges?
Did you try running the query in both ADO and DAO as a saved query?
Did you try running the query in both ADO and DAO as a query string?
When I test stored queries against stored queries I get the same
result: success.
When I test query strings against query strings I get the same results:
the error you describe.
Hello BillCo,
I think I see the problem.
In your query you are referring to another calculated field, I think that
is causing the problem.
Field DoubleAnswer should make it's own calculation and not be based on another
calculated field in the same query.
So, if you rewrite the query like this, it will work:
SELECT
A,
sum(B) as Answer1,
sum(B)* 2 as DoubleAnswer
From
Table
GROUP BY
A;
Regards,
Bas
I tried that, as it seemed the obvious answer - and no joy... same
failure notice. the only thing that worked was to not use compound
aggregates; to break down the formula to field level. (Or to use a
subquery)
bas wrote:
>Hello BillCo,
You have to change the group by in ADO to:
GROUP BY A, Answer1 * 2 as DoubleAnswer Regards, Bas
>>I 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 BY 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 BY 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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sausage31 |
last post by:
I have a table as follows....
Device LotID Result1 Result2 Result3
aaa 1 5 10 15
bbb 1 ...
|
by: neb |
last post by:
Dear member of the forum,
Ms access has built-in aggregate function like:
-Sum, Max, First, Avg, ...
Is it possible to build user-defined...
|
by: Eric Laberge |
last post by:
Aloha!
This question is meant to be about C99 and unnamed compound objects. As I
read, if such a construct as
int *p = (int){0};
is used within...
|
by: wespvp |
last post by:
I am using PostgreSQL 7.4.1 on RedHat 7.2.
The query I am executing is something like (I replaced all the return values
with 'count'):
db=>...
|
by: Najib Abi Fadel |
last post by:
Hi
i have an ordered table of dates let's say:
1/1/2004
8/1/2004
15/1/2004
29/1/2004
5/2/2004
12/2/2004
|
by: BillCo |
last post by:
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...
|
by: Ian825 |
last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. ...
|
by: vincibleman |
last post by:
Howdy all,
Working my way into SQL from Access. Think I might have the hang of the basics, but would really appreciate a sanity check. The...
|
by: Nate Eldredge |
last post by:
Consider the following pseudo-code:
#include <opaque.h>
struct foo {
int a;
opaque_t op;
int b;
};
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |