473,582 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADO Vs Jet/DAO for compound aggregate function

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.Op en "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?

Nov 9 '06 #1
5 6089
bas
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.Op en "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?

Nov 9 '06 #2
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.Op en "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?
Nov 10 '06 #3
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.Op en "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.

Nov 10 '06 #4
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 "qryCompoundAgg regate", cnCurrentConnec tion
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.
Nov 10 '06 #5
bas
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.Op en "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?

Nov 10 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2250
by: sausage31 | last post by:
I have a table as follows.... Device LotID Result1 Result2 Result3 aaa 1 5 10 15 bbb 1 2 4 6 aaa 2 3 6 9 I need to determine the mean of all results for each LotID, so used the Row Average function described on the Microsoft...
10
11917
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 aggregate? (if you have any clue, do not hesitate to post) *I'm running a total query, of the form
7
1929
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 a function, then it has "automatic storage duration associated with the enclosing block". So I tried the annexed code, and it compiles without a warning, and works as I expected.
8
3520
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=> explain select count(*) from messages m join (select * from message_recipients r join addresses a on a.Address_Key=r.Recipient where a.Address='lra.edi@edi.cma-cgm.com') as foo on...
1
2715
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
0
1574
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 aggregate functions like building blocks, e.g.: SELECT A, sum(B) as Answer1, Answer1 * 2 as DoubleAnswer
2
6098
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. My guess is that I need to dereference my pointers, but I'm not sure. Please help. The code: void equate(matrix *A, matrix *B) { int i, j; assert(A.row_dim == B.col_dim && A.col_dim ==...
4
3579
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 stored procedure listed below works, but I can't help but think there is a better way to do this. Gist of what I'm doing: I need aggregate error data for each satellite in tblSatellite. -Satellite...
27
2500
by: Nate Eldredge | last post by:
Consider the following pseudo-code: #include <opaque.h> struct foo { int a; opaque_t op; int b; };
0
7886
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8159
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8183
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.