Calculation from query

J

Jim

I have a query which gives me total records in the query and also
totals for each category type. I need an expression which will give
me a percentage. (category type) / (total records). can this be done
in an expression?
 
T

Tom van Stiphout

On Sun, 23 Aug 2009 18:18:29 -0700 (PDT), Jim <[email protected]>
wrote:

Here is one way, using A2007's Orders table. As you can see I used the
DCount function to get the overall total, and a groupby query to get
the total per category (CustomerID in this case).

SELECT Orders.[Customer ID], Count(Orders.[Order ID]) AS [CountOfOrder
ID], Count([order id])/DCount("[Order ID]","Orders") AS Percentage
FROM Orders
GROUP BY Orders.[Customer ID];

-Tom.
Microsoft Access MVP
 

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