2
我的主表包含時鐘輸入是TAD_REGISTER_VIEW。 表格很龐大,所以我只挑選一個ID爲004634的特定員工並顯示其記錄。如何在oracle PL中找到連續兩天的遲來員工SQL SQL
my table data is
1 004634 9/1/2017 9/1/2017 9:17:00 AM
2 004634 9/2/2017 9/2/2017 9:17:00 AM
3 004634 9/3/2017
4 004634 9/4/2017 9/4/2017 9:17:00 AM
5 004634 9/5/2017 9/5/2017 9:13:00 AM
6 004634 9/6/2017 9/6/2017 9:17:00 AM
7 004634 9/7/2017 9/7/2017 9:17:00 AM
8 004634 9/8/2017 9/8/2017 9:24:00 AM
9 004634 9/9/2017 9/9/2017 9:00:00 AM
10 004634 9/10/2017
11 004634 9/11/2017 9/11/2017 9:04:00 AM
12 004634 9/12/2017 9/12/2017 9:12:00 AM
13 004634 9/13/2017 9/13/2017 10:45:00 AM
14 004634 9/14/2017 9/14/2017 11:12:00 AM
15 004634 9/15/2017 9/15/2017 9:12:00 AM
我創建這個查詢之後9:15 AM找到的所有時間較晚記錄。 15分鐘是寬限期。 15分鐘後,他認爲後來者 我的查詢是
SELECT AR.EMPLOYEEID,
UPPER(AR.ATTENDANCETYPE) Att,
AR.CLOCKIN,
TO_CHAR(AR.ATTENDANCEDATE, 'dd-MON-yy') Day
FROM TAD_REGISTER_VIEW AR,
EMPMASTERINFO VEI,
SEC_EMPLOYEES S,
TAD_CALENDARDETAIL D
WHERE S.USERID = 'AFZAL'
AND S.MISFLAG = 1
AND AR.ATTENDANCEDATE BETWEEN '01-Sep-17' AND '30-Sep-17'
AND AR.EMPLOYEEID = VEI.EMPLOYEEID
AND AR.APPLICATIONID IS NULL
AND AR.CALENDARID = D.CALENDARID
AND S.EMPLOYEEID = VEI.EMPLOYEEID
AND AR.ATTENDANCETYPE = 'P'
AND AR.EMPLOYEEID= 004634
AND TRIM(TO_CHAR(AR.ATTENDANCEDATE, 'Day')) = TRIM(D.DAY)
AND TO_DATE(TO_CHAR(AR.CLOCKIN, 'fmHH:MI:SS AM'),
'fmHH:MI:SS AM') >=
TO_DATE(TO_CHAR(D.CLOCK_IN + 16/1440, 'fmHH:MI:SS AM'),
'fmHH:MI:SS AM')
ORDER BY AR.PATH, AR.EMPLOYEEID, AR.ATTENDANCEDATE;
從該查詢遲到的員工我的結果是
1 004634 P 9/1/2017 9:17:00 AM 01-SEP-17
2 004634 P 9/2/2017 9:17:00 AM 02-SEP-17
3 004634 P 9/4/2017 9:17:00 AM 04-SEP-17
4 004634 P 9/6/2017 9:17:00 AM 06-SEP-17
5 004634 P 9/7/2017 9:17:00 AM 07-SEP-17
6 004634 P 9/8/2017 9:24:00 AM 08-SEP-17
7 004634 P 9/13/2017 10:45:00 AM 13-SEP-17
8 004634 P 9/14/2017 11:12:00 AM 14-SEP-17
我想1個結果連續兩晚一天 如
2 004634 P 9/2/2017 9:17:00 AM 02-SEP-17
5 004634 P 9/7/2017 9:17:00 AM 07-SEP-17
7 004634 P 9/13/2017 10:45:00 AM 13-SEP-17
的超前滯後功能工作將很快更新你的。謝謝您的幫助 – Malik