1、维护数据
员工表
考勤表
2、查询迟到、早退数据
3、sql
SELECT
T.emp_no,
T.username,
T1.attendace_time,
T1.start_time,
T1.end_time,
CASE
WHEN DATE_FORMAT(T1.start_time, '%H') >= '09' THEN
'迟到'
END AS start_time_flag,
CASE
WHEN DATE_FORMAT(T1.end_time, '%H') <'17' THEN
'早退'
END AS end_time_flag
FROM
`员工表` T
INNER JOIN `考勤表` T1 ON T.emp_no = T1.emp_no
WHERE
DATE_FORMAT(T1.attendace_time, '%Y%m') = '201909' /*月份参数*/
这句是查询打卡记录
SELECT * from user u LEFT JOIN card c ON u.id = c.user_idWHERE u.id = c.user_id
先查出打卡记录的人,然后在user查询不包含打卡人的记录
SELECT * from user WHERE id not in (SELECT u.id from user u LEFT JOIN card c ON u.id = c.user_id
WHERE u.id = c.user_id and c.time > '2015-11-02'
and c.time < ' 2015-11-03' GROUP BY u.id
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)