- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关闭。这个问题需要debugging details .它目前不接受答案。
想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。
去年关闭。
Improve this question
我有不同的表格来跟踪员工出勤和假期,现在所有事情都已完成并且工作正常我想为面临一些问题的员工月度日历报告创建报告。
首先是
所有表都是:
1. hr_employee
2. hr_biometric出勤
1. hr_employee_leave
1. hr_employee_visits
1. hr_holidays
1. 15天前所有周六为工作日,15天后所有周六为公司假期
2. 在假期记录的日期范围内从日期到日期不是所有其他表的单个日期假期
我创建了一个查询,但它检索了多条记录,这对我来说是一个很难编写的查询。我怎样才能做到这一点?
这是查询:
SET @fromDate = "2019-12-01";
SET @toDate = "2019-12-31";
SET @empId = 2814;
SET @recordStatus = "ATT";
SELECT
att.time_checked AS checkedTIme, @recordStatus
FROM
hr_employee emp
JOIN hr_biometric_attendance att ON att.`employee_id` = emp.id
WHERE emp.id = @empId
AND att.`time_checked` BETWEEN @fromDate AND @toDate
UNION
SELECT v.selected_date, "HD" FROM
(SELECT ADDDATE('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date FROM
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t0,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t1,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t2,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t3,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t4) v
,
(SELECT hDay.date_from df, hDay.date_to dt FROM `hr_holiday` hDay WHERE hDay.date_from >= @fromDate AND hDay.date_to <= @toDate) hDayQ
WHERE selected_date BETWEEN hDayQ.df AND hDayQ.dt
UNION
SELECT v1.selected_date1, "EV" FROM
(SELECT ADDDATE('1970-01-01',t41.i*10000 + t31.i*1000 + t21.i*100 + t11.i*10 + t01.i) selected_date1 FROM
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t01,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t11,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t21,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t31,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t41) v1
,
(SELECT hEmpV.date_from df, hEmpV.date_to dt FROM `hr_employee_visit` hEmpV WHERE hEmpV.employee_id = @empId) hEmpVQ
WHERE selected_date1 BETWEEN hEmpVQ.df AND hEmpVQ.dt
UNION
SELECT v2.selected_date2, "EL" FROM
(SELECT ADDDATE('1970-01-01',t42.i*10000 + t32.i*1000 + t22.i*100 + t12.i*10 + t02.i) selected_date2 FROM
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t02,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t12,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t22,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t32,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t42) v2
,
(SELECT hEmpL.date_from df, hEmpL.date_to dt FROM `hr_employee_leave` hEmpL WHERE hEmpL.employee_id = @empId) hEmpLQ
WHERE selected_date2 BETWEEN hEmpLQ.df AND hEmpLQ.dt
UNION DISTINCT
SELECT v3.selected_date3, (SELECT IF(DAYNAME(v3.selected_date3) ='Sunday' OR (DAYOFMONTH(v3.selected_date3) >= 15 AND DAYNAME(v3.selected_date3) ='saturday'),'H','W'))
FROM
(SELECT ADDDATE('1970-01-01',t43.i*10000 + t33.i*1000 + t23.i*100 + t13.i*10 + t03.i) selected_date3 FROM
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t03,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t13,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t23,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t33,
(SELECT 0 i UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) t43) v3
WHERE selected_date3 BETWEEN @fromDate AND @toDate
ORDER BY `checkedTIme`;
最佳答案
就像我在评论中所说的那样,为了简化查询,您应该创建一个专用 calendar
表,以便您可以缩短查询。引用:https://www.db-fiddle.com/f/qVgmfDaVUszABAyFzH7iUS/0
完成后,您可以按如下方式重新编写查询:
SET @fromDate = "2019-12-01";
SET @toDate = "2019-12-31";
SET @empId = 2814;
SET @recordStatus = "ATT";
SELECT att.time_checked AS checkedTIme, @recordStatus FROM hr_employee emp
JOIN hr_biometric_attendance att ON att.`employee_id` = emp.id
WHERE emp.id = @empId
AND att.`time_checked` BETWEEN @fromDate AND @toDate
UNION
SELECT v.selected_dates, "HD" FROM calendar v JOIN
(SELECT hDay.date_from df, hDay.date_to dt FROM `hr_holiday` hDay
WHERE hDay.date_from >= @fromDate AND hDay.date_to <= @toDate) hDayQ
ON selected_dates BETWEEN hDayQ.df AND hDayQ.dt
UNION
SELECT v1.selected_dates, "EV" FROM calendar v1 JOIN
(SELECT hEmpV.date_from df, hEmpV.date_to dt FROM `hr_employee_visit` hEmpV
WHERE hEmpV.employee_id = @empId) hEmpVQ
ON selected_dates BETWEEN hEmpVQ.df AND hEmpVQ.dt
UNION
SELECT v2.selected_dates, "EL" FROM calendar v2 JOIN
(SELECT hEmpL.date_from df, hEmpL.date_to dt FROM `hr_employee_leave` hEmpL
WHERE hEmpL.employee_id = @empId) hEmpLQ
ON selected_dates BETWEEN hEmpLQ.df AND hEmpLQ.dt
UNION DISTINCT
SELECT v3.selected_dates, (SELECT IF(DAYNAME(v3.selected_dates) ='Sunday'
OR (DAYOFMONTH(v3.selected_dates) >= 15 AND DAYNAME(v3.selected_dates) ='saturday'),'H','W'))
FROM calendar v3
WHERE selected_dates BETWEEN @fromDate AND @toDate
ORDER BY `checkedTIme`;
关于mysql - iReport中的员工考勤日历报表设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59727883/
我希望通过 Workday API 检索 Workday 工作人员(又名员工)Web 配置文件 URL。用例是我正在构建一个聊天机器人来检索用户信息,并且我希望能够深度链接到工作人员(员工)网络配置文
我很困惑我希望员工 ID 是自动生成的前缀格式我知道在 sql server 中触发之前是可能的我正在关注帖子 http://www.aspdotnet-suresh.com/2012/04/set-
我读了一个教程,其中有这个结构: struct { char Name[25]; int Age; float SkillRating; } Employee; defines
我有两个表 employee(name,id) ,其中包含所有员工和另一个表 reader(id,date) ,它给出了日期和哪个员工在场。我如何找到一定范围内的缺席者列表日期? 对于特定日期,我能够
我需要员工 ID 的标准正则表达式,例如 EMP015 015EMP EMP_015 E_015 EMP-015 EMP.VIS EMP/056 基本上它应该允许 . 或 _ 或 - 或 / 在字母数
我是 Angular 的新手,正在使用 Angular 编写代码,我正在观看视频教程。我注意到我的代码中有一些东西,但我无法理解它是如何工作的。 我想知道这段代码是什么意思组件上的“员工:员工 []”
下面从HR角度,来分析员工离职成本,欢迎大家留言讨论。 一个员工离职后留下的坑,并不是再找一个人填上就万事大吉了。 一般来说,核心人才的流失,至少有1-2个月的招聘期、3个月的适应期,6个月的融入期;
我有两个表 Employee 和 Department 此图像显示每个员工的经理。我想编写一个 SQL 查询,为我提供所有主管(经理、经理的经理......)的列表。 我只想要一个列,在给定特定员工时
我想将 ER 图的这一部分转换为关系模型。我们有一个三元关系,它说的是以下内容: 1 位客户将 1 个项目提供给 -> 多个开发人员 1 位客户分配给 1 位开发人员 -> 多个项目 1 个开发人员被
我将要开发一个应用程序,该应用程序将使用一些基于 SOAP 的 Web 服务框架。我做了一些研究,我有点喜欢 Axis2C 框架,但在某些主题中,我发现原来的 Axis2C 实现存在内存泄漏问题,并且
我的 SQL 数据库中有两个表: 公司: ID(自增) 姓名 地址 ... 员工: ID(自增) 公司编号 internal_id 姓名 姓氏 问题是我想要一个与他们所属的公司相关的员工 ID (in
我试图在堆栈溢出和谷歌上找到这个问题的答案,但没有找到。如果有问题需要更正或重复问题,请告诉我。 当我计算员工对象 (emp_obj) 和员工类的大小时,在这两种情况下我都得到了 4 个字节。但是我不
问题 如何在 Angular 员工 component.html 上返回 EmployeeCode ? 示例数据引用表 Code tableName FieldName LabelText
我是 hibernate 新手,正在使用 hibernate 版本 4.3.4 JAR 文件。我正在尝试使用 intelliJ 社区版中的 mySQL 服务器执行简单的 Hibernate 程序。以下
我正在使用 laravel 5.4 和 Yajra Datatable,但我无法使其工作..我遇到了“Uncaught TypeError: $(...).DataTable is not a fun
我想创建一个小型示例应用程序,它可以读取我的员工徽章并将其显示在屏幕上(或者如果我可以复制它就更好了,这样我们就可以使用我们的手机徽章而不是我们的塑料身份证) 几个问题1. 这在技术上可行吗?如果是这
我有一个 person 对象,需要将它存储为 byte[] 并再次检索该 byte[] 并转换为 person 对象 并且 BinaryFormatter 在 Silverlight 中不可用 最佳答
最近开始学习oracle和sql。 在学习的过程中,我遇到了几个问题,我的 friend 在接受采访时被问到这些问题。 SELECT * FROM Employees WHERE NULL IS N
当我执行以下命令来创建分片时: mysqlfabric sharding add_table 1 employees.employees emp_no 我收到以下错误: DatabaseError:
这是我的表格 门票 tic_id, tic_cat tic_priority tic_cus tic_date tic_title tic_
我是一名优秀的程序员,十分优秀!