数据库,查询所有部门的部门编码、名称和早退人数,以早退人数降序,部门编码升序排列

这篇博客介绍了三个数据库表格的创建,包括部门表`t_dept`、员工表`t_staff`和考勤表`t_attendance`,并展示了如何插入数据。部门包括业务部、开发部和运维部,员工分布在不同部门,考勤记录了员工的打卡时间和时长。
摘要由CSDN通过智能技术生成

在这里插入图片描述

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');

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一蓑烟雨渡平生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值