SELECT DISTINCTROW TIMEKEEPING.EMPLOYEENumber, Employees.FirstName,
Employees.LastName, TRADES.Trade, Employees.Salary, Employees.Agency,
Employees.HourlySalary,
IIf([agency]="afs",1.38,IIf([agency]="iss",1.365,IIf([agency]="TSI",1.37,0)))
AS Markup, [salary]*[markup] AS SalaryMarkup,
IIf([agency]="afs",[sumofreghrs]*[salarymarkup],IIf([agency]="iss",[sumofreghrs]*[salarymarkup],IIf([agency]="tsi",[sumofreghrs]*[salarymarkup],IIf([agency]="qc"
And [hourlysalary]="s",[salary]*520,IIf([agency]="qc" And
[hourlysalary]="h",[salary]*[sumofreghrs],0))))) AS RegCost,
IIf([agency]="afs",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="iss",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="tsi",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="qc"
And [hourlysalary]="s",0,IIf([agency]="qc" And
[hourlysalary]="h",[salary]*[sumofothrs]*1.5,0))))) AS OtCost,
[regcost]/[sumofreghrs] AS AudManhrRegRate, [otcost]/[sumofothrs] AS
AudManhrOtRate, Sum(TIMEKEEPING.reghrs) AS sumreghrs, Sum(TIMEKEEPING.othrs)
AS sumothrs
FROM (Employees LEFT JOIN TIMEKEEPING ON
Employees.EmployeeNumber=TIMEKEEPING.EMPLOYEENumber) INNER JOIN TRADES ON
Employees.Trade=TRADES.[AUTOTRADE#]
GROUP BY TIMEKEEPING.EMPLOYEENumber, Employees.FirstName,
Employees.LastName, TRADES.Trade, Employees.Salary, Employees.Agency,
Employees.HourlySalary,
IIf([agency]="afs",1.38,IIf([agency]="iss",1.365,IIf([agency]="TSI",1.37,0))),
[salary]*[markup],
IIf([agency]="afs",[sumofreghrs]*[salarymarkup],IIf([agency]="iss",[sumofreghrs]*[salarymarkup],IIf([agency]="tsi",[sumofreghrs]*[salarymarkup],IIf([agency]="qc"
And [hourlysalary]="s",[salary]*520,IIf([agency]="qc" And
[hourlysalary]="h",[salary]*[sumofreghrs],0))))),
IIf([agency]="afs",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="iss",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="tsi",[sumofothrs]*[salarymarkup]*1.5,IIf([agency]="qc"
And [hourlysalary]="s",0,IIf([agency]="qc" And
[hourlysalary]="h",[salary]*[sumofothrs]*1.5,0))))), [regcost]/[sumofreghrs],
[otcost]/[sumofothrs], TIMEKEEPING.REGHRS, TIMEKEEPING.OTHRS;