How do I get Percentages of Groups from one table?

K

Kelly

I am a new user to Access and am trying to set up queries and perform
calculatons. I have one big list of postal codes, state names and country
names that we have taken from visitors as they come into our centre. I've
been asked to develop a database to determine say what percentage of our
visitors come from a certain postal code area or state. So I have to
determine the total number of visitors which will increase each day and then
prompt the user to enter the state, and possibly the month. How do I set up
the queries & criteria to do this? Any adivice would be great. Thank you so
much!
 
D

Dale Fye

Kelly,

You will probably need to create two queries, one to give you the counts for
a particular state and all states, the other to give you the percentages.

Query 1:

SELECT State
, SUM(IIF([State] = [Visitors State], 1, 0)) as StateCount,
, SUM(1) as MonthCount
FROM your Table
WHERE VisitMonth = [What Month]
GROUP BY State

Query 2:
Select State, StateCount, MonthCount, StateCount/MonthCount * 100
FROM Query1

You could add a column to query 1 that does the summations and the division
in a single query, but this method is probably tidier.

HTH
Dale
 

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