我试图加入我的查询,但我被困在周日时间,
我有一个非常基本且直接的联接查询,用于计算员工的所有工作时间、正常时间和加班时间,并且查询运行良好,但是当我想加入星期天时间时,一切都变得混乱了......
没有周日时间的完整查询:-
SELECT
`empl_attendance`.`employee_id`,
`employee`.`employee_surname`,
`employee`.`employee_first_name`,
`employee`.`employee_second_name`,
FORMAT((IF(SUM...some basic maths...)),1) AS nt,
FORMAT((...some basic maths...),1) AS ot,
FORMAT((...some basic maths...),1) AS total
FROM
`empl_attendance`
WHERE
(`empl_attendance_date` BETWEEN '$start_date' AND '$end_date')
INNER JOIN
`employee`
ON `empl_attendance`.`employee_id`=`employee`.`employee_id`
GROUP BY `employee_id`
但是我需要结合下面的查询,它基本上计算了每个员工的周日总小时数。该查询本身可以正常工作,我只是在努力结合这两个查询:
SELECT SUM(`empl_attendance_total`) AS sundays
FROM `empl_attendance`
WHERE
(`empl_attendance_date` BETWEEN '$start_date' AND '$end_date')
AND
WEEKDAY(`empl_attendance_date`) > 5
GROUP BY `employee_id`
谢谢
周杰伦