Calculating percentages from COUNT?

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

I have a very simple Totals query which counts the number of enquiries for
each customer, grouping by the customer field and counting the customerID
field.

I want to be able to give the count as a percentage of the total number of
enquiries. How do I do this?

Any help greatly appreciated.

Regards

Jason
 
Jay said:
I have a very simple Totals query which counts the number of enquiries for
each customer, grouping by the customer field and counting the customerID
field.

I want to be able to give the count as a percentage of the total number of
enquiries. How do I do this?


Use a subquery to calculate the total count. set your
percent column to something like:

Count(*) / (SELECT Count(*) FROM table)
 
Thanks Marshall,

I don't really understand you (please forgive my newbie stumblings)

Do you mean do the total count in another query and then use that field
in my original query?

Thanks,

Jason
 
Well, I meant for that to be a calculated field in your
existing query, but since I didn't see your query, I can't
be sure that it would be complete. To make sure please post
a Copy/Paste of your query's SQL view.
 
Hi Marsh, sql-view below

SELECT [Tbl_Query Support Log].Customer, Count([Tbl_Query Support
Log].[Query ID]) AS [Number of Queries]
FROM [Tbl_Query Support Log]
GROUP BY [Tbl_Query Support Log].Customer
ORDER BY Count([Tbl_Query Support Log].[Query ID]) DESC;

many thanks,


jason

Marshall Barton said:
Well, I meant for that to be a calculated field in your
existing query, but since I didn't see your query, I can't
be sure that it would be complete. To make sure please post
a Copy/Paste of your query's SQL view.
--
Marsh
MVP [MS Access]

I don't really understand you (please forgive my newbie stumblings)

Do you mean do the total count in another query and then use that field
in my original query?
 
To avoid all the extra [ ]s and redundant table names, etc,
just Paste the below SQL statement over your query's SQL
view.

SELECT Customer,
Count(*) AS [Number of Queries],
Count(*) / (SELECT Count(*)
FROM [Tbl_Query Support Log]) As Pct
FROM [Tbl_Query Support Log]
GROUP BY Customer
ORDER BY Count(Query ID) DESC
--
Marsh
MVP [MS Access]

SELECT [Tbl_Query Support Log].Customer, Count([Tbl_Query Support
Log].[Query ID]) AS [Number of Queries]
FROM [Tbl_Query Support Log]
GROUP BY [Tbl_Query Support Log].Customer
ORDER BY Count([Tbl_Query Support Log].[Query ID]) DESC;


Well, I meant for that to be a calculated field in your
existing query, but since I didn't see your query, I can't
be sure that it would be complete. To make sure please post
a Copy/Paste of your query's SQL view.
 
Thanks Marsh,

I appreciate your help. I've always done a count as a percentage query with
2 queries so this has really helped my understanding.

Rgds

Jason

Marshall Barton said:
To avoid all the extra [ ]s and redundant table names, etc,
just Paste the below SQL statement over your query's SQL
view.

SELECT Customer,
Count(*) AS [Number of Queries],
Count(*) / (SELECT Count(*)
FROM [Tbl_Query Support Log]) As Pct
FROM [Tbl_Query Support Log]
GROUP BY Customer
ORDER BY Count(Query ID) DESC
--
Marsh
MVP [MS Access]

SELECT [Tbl_Query Support Log].Customer, Count([Tbl_Query Support
Log].[Query ID]) AS [Number of Queries]
FROM [Tbl_Query Support Log]
GROUP BY [Tbl_Query Support Log].Customer
ORDER BY Count([Tbl_Query Support Log].[Query ID]) DESC;


Well, I meant for that to be a calculated field in your
existing query, but since I didn't see your query, I can't
be sure that it would be complete. To make sure please post
a Copy/Paste of your query's SQL view.


Jay wrote:
I don't really understand you (please forgive my newbie stumblings)

Do you mean do the total count in another query and then use that field
in my original query?


Marshall Barton wrote:
Jay wrote:

I have a very simple Totals query which counts the number of
enquiries
for
each customer, grouping by the customer field and counting the
customerID
field.

I want to be able to give the count as a percentage of the total
number
of
enquiries. How do I do this?


Use a subquery to calculate the total count. set your
percent column to something like:

Count(*) / (SELECT Count(*) FROM table)
 

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

Back
Top