我试图弄清3个等级(普通,加班1.5和加班2.0)的值,然后确定'普通'是否等于8,如果是,则计算(SUM-0.4) )/7.6。如果没有,那么它只是(SUM / 7.6)......这样我就可以计算出全职员工的人数。
所以这就是我现在所处的位置。这些值似乎并不是我手动计算的结果,我认为我的过程是错误的:
SELECT Supervisor,
SUM(CASE WHEN DAYOFWEEK(workdate) = 2 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Monday`,
SUM(CASE WHEN DAYOFWEEK(workdate) = 3 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Tuesday`,
SUM(CASE WHEN DAYOFWEEK(workdate) = 4 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Wednesday`,
SUM(CASE WHEN DAYOFWEEK(workdate) = 5 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Thursday`,
SUM(CASE WHEN DAYOFWEEK(workdate) = 6 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Friday`,
SUM(CASE WHEN DAYOFWEEK(workdate) = 7 THEN IF(employeehours.paycode = '01 Ordinary' AND employeehours = 8,((employeehours-0.4)/7.6),(employeehours/7.6)) END) `Saturday`
FROM payroll.employeedatanew_copy
JOIN payroll.employeehours ON employeedatanew_copy.`ID Number` = employeehours.employeeid
WHERE employeehours.workdate BETWEEN '2013-12-02' AND '2013-12-07'
GROUP BY supervisor