Re: Querying mean values without using "Totals"
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Thu, 15 Nov 2007 14:55:57 -0500
You cannot use an aggregate in a WHERE clause. Try using it in an HAVING
clause. The WHERE clause is executed BEFORE any aggregation, so, the result
of the aggregation cannot be tested in it, at that stage.
SELECT id, AVG(something)
FROM somewhere
GROUP BY id
HAVING AVG(something) >= (SELECT AVG(something) FROM somewhere)
will return the groups 'id' where their average is larger than the average
of the whole table.
Vanderghast, Access MVP
"gabriel" <gabriel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7D879DE0-6781-4A36-BE8E-E9F98FBA779A@xxxxxxxxxxxxxxxx
Dear Access Community
I'm a novice regarding Access and have an apperently simple problem.
I want to query the average of a numeric field, without using the "Totals"
approach.
Using the expression builder with the function "Avg" in the cell
"criteria"
causes following error message (I translated the message from portuguese
into
english, so the original message is probably a little different: "It is
not
possible to have a aggregated function in a WHERE instance".
Can anybody help me ?
Thanks a lot !
gabriel
.
- Prev by Date: Re: Help with "Like" Criteria
- Next by Date: Month sum
- Previous by thread: Re: Help with "Like" Criteria
- Next by thread: RE: Querying mean values without using "Totals"
- Index(es):
Relevant Pages
|