Percentage Query

G

Guest

I need to do a percentage query with the following fields from my table

Department
Last Name
First Name
Active (this is a yes/no button which is checked if active)
Termination Date

I need to run a query to show the percentage of employees who where terminated during a given time period (eg 1 Jun to 30 Jun 04). This query needs to be run for each department and the start and end date will vary depending on which month the query will be run in. Not sure if I need to do a between date or just by month.
 
M

Michel Walsh

Hi,


SELECT Abs( SUM(Active) ) / COUNT(*) As percentage,
Month(TerminationDate), Year(TerminationDate)
FROM myTable
GROUP BY month(TerminationDate), , Year(TerminationDate)


would work, based on that true is represented by -1, while false is
represented by 0. Summing those will give the number of time there is a true
( with a negative sign, that is why I use ABS( ) to get the absolute
value; can have use - SUM(actve) / COUNT(*) ).



Hoping it may help,
Vanderghast, Access MVP



Max said:
I need to do a percentage query with the following fields from my table

Department
Last Name
First Name
Active (this is a yes/no button which is checked if active)
Termination Date

I need to run a query to show the percentage of employees who where
terminated during a given time period (eg 1 Jun to 30 Jun 04). This query
needs to be run for each department and the start and end date will vary
depending on which month the query will be run in. Not sure if I need to do
a between date or just by month.
 

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