Very daft percentage calculation

S

scubadiver

I have a number of fields with absence information and calculated the total.
I want to calculate [Abs_PH] as a percentage of the total. Here is a
simplified SQL


SELECT tble_employee.WorkStat, tble_week.Period, tble_hrs.Dept,
Sum(tble_hrs.Abs_PH) AS [Paid Hol],
Sum([Abs_PH]+[Abs_PSL]+[Abs_MA]+[Abs_Train]+[Abs_CL]+[Abs_SPL]+[Abs_UPH]+[Abs_USL]) AS Total
FROM tble_week INNER JOIN (tble_employee INNER JOIN tble_hrs ON
tble_employee.EmployeeID = tble_hrs.EmployeeID) ON tble_week.RecWk =
tble_hrs.RecWk
GROUP BY tble_employee.WorkStat, tble_week.Period, tble_hrs.Dept;
 
K

KARL DEWEY

You should have a separate record per employee per week for each type of
hours and use a field for type and another for hours.
--
KARL DEWEY
Build a little - Test a little


scubadiver said:
I've done it.

scubadiver said:
I have a number of fields with absence information and calculated the total.
I want to calculate [Abs_PH] as a percentage of the total. Here is a
simplified SQL


SELECT tble_employee.WorkStat, tble_week.Period, tble_hrs.Dept,
Sum(tble_hrs.Abs_PH) AS [Paid Hol],
Sum([Abs_PH]+[Abs_PSL]+[Abs_MA]+[Abs_Train]+[Abs_CL]+[Abs_SPL]+[Abs_UPH]+[Abs_USL]) AS Total
FROM tble_week INNER JOIN (tble_employee INNER JOIN tble_hrs ON
tble_employee.EmployeeID = tble_hrs.EmployeeID) ON tble_week.RecWk =
tble_hrs.RecWk
GROUP BY tble_employee.WorkStat, tble_week.Period, tble_hrs.Dept;
 

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

cumulative DSum 4

Top