Error in Query using avg function

G

Guest

I am running a query with the following function =avg([test1]+[test2]+test3])
I get an error message to say that the test1 expression is not part of the
aggregrate function. The field name is definately test1, if I omit test1 i
get the same message refering to test2 - Help Plz
 
K

kingston via AccessMonster.com

What are you trying to average? The three fields within a single record or
all of the records combined? It sounds like you're trying to do the former
but have a totals query which does the latter. If you want the average for a
single record, use your formula in a query field and don't use a totals query.
HTH
I am running a query with the following function =avg([test1]+[test2]+test3])
I get an error message to say that the test1 expression is not part of the
aggregrate function. The field name is definately test1, if I omit test1 i
get the same message refering to test2 - Help Plz
 
G

Guest

The avg function can only be used in a Totals Query. You should be averaging
based on some other field, I would guess

SELECT SomeField, Avg([test1]+[test2]+[test3]) AS YrAvg
FROM SomeTable
GROUP BY SomeField;
 
D

David F Cox

If it is the case that it is three fields within each record then it is
([test1]+[test2]+[test3]}/3

Klatuu said:
The avg function can only be used in a Totals Query. You should be
averaging
based on some other field, I would guess

SELECT SomeField, Avg([test1]+[test2]+[test3]) AS YrAvg
FROM SomeTable
GROUP BY SomeField;

Mairtin said:
I am running a query with the following function
=avg([test1]+[test2]+test3])
I get an error message to say that the test1 expression is not part of
the
aggregrate function. The field name is definately test1, if I omit test1
i
get the same message refering to test2 - Help Plz
 
G

Guest

Yip have tried that and it works!!! when reading the help file I thought I
could use teh AVG function. What I am trying to do is average values in one
record in an additional column in the query. I gather from the replies that
the avg function doesnt work in this case!!!

David F Cox said:
If it is the case that it is three fields within each record then it is
([test1]+[test2]+[test3]}/3

Klatuu said:
The avg function can only be used in a Totals Query. You should be
averaging
based on some other field, I would guess

SELECT SomeField, Avg([test1]+[test2]+[test3]) AS YrAvg
FROM SomeTable
GROUP BY SomeField;

Mairtin said:
I am running a query with the following function
=avg([test1]+[test2]+test3])
I get an error message to say that the test1 expression is not part of
the
aggregrate function. The field name is definately test1, if I omit test1
i
get the same message refering to test2 - Help Plz
 
M

Michel Walsh

Hi,


AVG works vertically, not horizontally; it works across records, not across
fields.

AVG can support expression, such as AVG(10*x) which would be the same as
10*AVG(x), here, but less trivial can be something like AVG(x*x) which
would average the square of the values in the field x.


In your initial first case, you were building an expression of three actual
fields, x1+x2+x3 (if one is null, the result is also null) and once that
sum was made, AVG was working vertically, through all the record, making the
same sum for each records, first.


Hoping it may help,
Vanderghast, Access MVP

Mairtin said:
Yip have tried that and it works!!! when reading the help file I thought I
could use teh AVG function. What I am trying to do is average values in
one
record in an additional column in the query. I gather from the replies
that
the avg function doesnt work in this case!!!

David F Cox said:
If it is the case that it is three fields within each record then it is
([test1]+[test2]+[test3]}/3

Klatuu said:
The avg function can only be used in a Totals Query. You should be
averaging
based on some other field, I would guess

SELECT SomeField, Avg([test1]+[test2]+[test3]) AS YrAvg
FROM SomeTable
GROUP BY SomeField;

:

I am running a query with the following function
=avg([test1]+[test2]+test3])
I get an error message to say that the test1 expression is not part of
the
aggregrate function. The field name is definately test1, if I omit
test1
i
get the same message refering to test2 - Help Plz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top