求mysql大佬指教,mysql考勤查询

求mysql大佬指教,mysql考勤查询,第1张

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' /*月份参数*/

mysql更新表中数据的存储过程,代码如下:

mysql>CREATE TABLE Employee( //创建表

->idint,

->first_nameVARCHAR(15),

->last_name VARCHAR(15),

->start_dateDATE,

->end_date DATE,

->salaryFLOAT(8,2),

->city VARCHAR(10),

->description VARCHAR(15)

->)

Query OK, 0 rows affected (0.01 sec)

--//导入数据

mysql>insert into Employee(id,first_name, last_name, start_date, end_Date, salary, City, Description)

-> values (1,'Jason','Martin', '19960725', '20060725', 1234.56, 'Toronto', 'Programmer')

Query OK, 1 row affected (0.00 sec)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6101818.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-14
下一篇 2023-03-14

发表评论

登录后才能评论

评论列表(0条)

保存