我有一张桌子“出席”
我想找出连续3天缺席的员工。在表格中列出了所有员工的缺席日期。
我使用的数据库是Oracle 10G。
答案 0 :(得分:5)
SELECT DISTINCT A.EMPLOYEENAME
FROM Attendance AS A
JOIN Attendance AS B ON B.LEAVE_DATE = A.LEAVE_DATE + 1 AND B.EMPLOYEENAME = A.EMPLOYEENAME
JOIN Attendance AS C ON C.LEAVE_DATE = B.LEAVE_DATE + 1 AND C.EMPLOYEENAME = B.EMPLOYEENAME
内部联接将删除所有连续三天没有缺席的员工。