Seems so simple - Percentage

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with the code designation in one column and the number of
records with that code in the other column. I need to find out what
percentage of the total records in the table has each code. Seems so simple
but I cannot get the query to work!

Please help.

Thanks.
 
SELECT ASIF.TABLE_NAME,
Count(ASIF.TABLE_NAME) AS TheCount,
Format([TheCount]/DCount("[ID]","ASIF"),"Percent") AS Expr1
FROM ASIF
GROUP BY ASIF.TABLE_NAME;

Try something like the above with the proper table and field names. ID is
the primary key field for the table. Using a PK field makes sure that nulls
won't mess up things.
 
You don't need to store the number of rows per code in a column; you can
compute that in a query and at the same time get the percentage of the total
number of rows, e.g.

SELECT Code, COUNT(*) As NumberPerCode,
100*COUNT(*)/
(SELECT COUNT(*)
FROM YourTable)
AS Percentage
FROM YourTable
GROUP BY Code;

Ken Sheridan
Stafford, England
 
Thank you!

Ken Sheridan said:
You don't need to store the number of rows per code in a column; you can
compute that in a query and at the same time get the percentage of the total
number of rows, e.g.

SELECT Code, COUNT(*) As NumberPerCode,
100*COUNT(*)/
(SELECT COUNT(*)
FROM YourTable)
AS Percentage
FROM YourTable
GROUP BY Code;

Ken Sheridan
Stafford, England
 
Thank you!

Jerry Whittle said:
SELECT ASIF.TABLE_NAME,
Count(ASIF.TABLE_NAME) AS TheCount,
Format([TheCount]/DCount("[ID]","ASIF"),"Percent") AS Expr1
FROM ASIF
GROUP BY ASIF.TABLE_NAME;

Try something like the above with the proper table and field names. ID is
the primary key field for the table. Using a PK field makes sure that nulls
won't mess up things.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Danu said:
I have a table with the code designation in one column and the number of
records with that code in the other column. I need to find out what
percentage of the total records in the table has each code. Seems so simple
but I cannot get the query to work!

Please help.

Thanks.
 

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

Similar Threads

Querying Dates 5
Percentages Total 3
Access Dcount (multiple criteria) 3
Problem Creating Totals Query 1
Percentage Change 2
Force Percentage Form 1
Access Group by precinct, calculate percentage of older voters 0
Calculation from query 1

Back
Top