A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Seems so simple - Percentage



 
 
Thread Tools Display Modes
  #1  
Old May 16th, 2007, 05:13 PM posted to microsoft.public.access.queries
Danu
external usenet poster
 
Posts: 76
Default Seems so simple - Percentage

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.


  #2  
Old May 16th, 2007, 05:24 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Seems so simple - Percentage

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" wrote:

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.


  #3  
Old May 16th, 2007, 07:06 PM posted to microsoft.public.access.queries
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default Seems so simple - Percentage

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

"Danu" wrote:

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.



  #4  
Old May 16th, 2007, 07:28 PM posted to microsoft.public.access.queries
Danu
external usenet poster
 
Posts: 76
Default Seems so simple - Percentage

Thank you!

"Ken Sheridan" wrote:

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

"Danu" wrote:

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.



  #5  
Old May 16th, 2007, 07:28 PM posted to microsoft.public.access.queries
Danu
external usenet poster
 
Posts: 76
Default Seems so simple - Percentage

Thank you!

"Jerry Whittle" wrote:

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" wrote:

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.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.