Calculating Percentage in Query.

G

Guest

I have a query with the fields

Quantity (Count of ID's), Product, company.

My issue is to calculate the percentage for each company in a query

When I put Quantity/Sum(Quantity)) I am getting subquery warning. How can I
accomlish this in a query.

That is , I would like to get
Quantity, Percenage: Qty/Sum(Qty), Company.

Any help really appreciated.

Thank you
 
G

Guest

Create a totals query to get your SUMs for the equation.
Join the query with your table in that output query to get percent.
 
G

Guest

May be I am mis understanding or I do not know.

I guess When I create totals query I will get the totals. However ho do I
join the two tables?
 
W

Wolfgang Kais

Hello Lin.

Lin said:
I have a query with the fields

Quantity (Count of ID's), Product, company.

My issue is to calculate the percentage for each company in a query

When I put Quantity/Sum(Quantity)) I am getting subquery warning.
How can I accomlish this in a query.

That is , I would like to get
Quantity, Percenage: Qty/Sum(Qty), Company.

Any help really appreciated.

Thank you

How about this:
Select company, Count(ID) as Quantity,
Count(ID)/(Select Count(ID) From YouTableName) as Percentage
From YourTableName Group By company
 

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