create table t_dept(id bigint, code varchar(20), name varchar(20));
create table t_staff(id bigint, code varchar(20), name varchar(20),mobile varchar(20), dept_id bigint);
create table t_attendance(id bigint, dept_id bigint, staff_id bigint, day date, checkin_time datetime, checkout_time datetime, attend_duration long);
insert into t_dept(id,code,name) values
(1, '01', '业务部'),
(2, '02', '开发部'),
(3, '03', '运维部');
insert into t_staff(id, code, name, dept_id) values
(1, 'zs', '张三', 1),
(2, 'ls', '李四', 1),
(3, 'ww', '王五', 2),
(4, 'lb', '李白', 2),
(5, 'zl', '张良', 3),
(6, 'cc', '曹操', 3);
insert into t_attendance(id, dept_id, staff_id, day, checkout_time) values
(1, 1, 1, '2021-07-01', '2021-07-01 16:25:00'),
(2, 1, 2, '2021-07-01', '2021-07-01 16:40:00'),
(3, 2, 3, '2021-07-01', '2021-07-01 16:26:00'),
(4, 2, 4, '2021-07-01', '2021-07-01 17:45:00'),
(5, 3, 5, '2021-07-01', '2021-07-01 16:25:00'),
(6, 3, 6, '2021-07-01', '2021-07-01 18:25:00');
数据库,查询所有部门的部门编码、名称和早退人数,以早退人数降序,部门编码升序排列
最新推荐文章于 2022-10-22 22:44:34 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)