Calculating average within groups

N

NeedAccessHelp!

I'm attempting to study from home and got stuck on a question. I need to
create a query to calculate the average age of pets, grouped by the pet type
(i.e. dog, cat etc).

Just wondering if anyone can help me! It would be greatly appreciated!

Thanks!
 
A

Al Campagna

We'll neeed to know what your data looks like, Could you provide just a
few simple example of records... say for just dogs, and what you want the
calulation to yield.
But... usually it's an unbound calculated field in the appropriate Group
Footer...
(ex. field to be averaged DogCount)
= Avg(DogCount)
or
= Sum(DogCount) / Count(DogCount)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
N

NeedAccessHelp!

my data is as follows:

PetType Pet Age

Budgie 3

Cat 3
Cat 4
Cat 5

Dog 3
Dog 9
Dog 8
Dog 3

I need to somehow separate each pet "type", and average the ages given in
each section.
 
D

Duane Hookom

If this is homework, you should find and read information on SQL syntax. This
sounds like a very basic totals/group by query. The Access query design makes
this very easy to create.

Your final syntax might look something like:

SELECT PetType, Avg([Pet Age]) As AvgAge
FROM [my data is as follows]
GROUP BY PetType;
 

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