Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

select and group continuous absenteeism days

$
0
0

Hi guys,

I have a table being generated by a query in the db server that displays the below data... This is part of a scheduled job that has been designed to trigger mails to only the employees consecutively absent.

EMP_CODE ATTENDANCE_DATE ATTENDANCE_STATUS
100001 6-Apr W
100001 5-Apr W
100001 4-Apr A
100001 3-Apr A
100001 2-Apr A
100001 1-Apr P
100002 6-Apr W
100002 5-Apr L
100002 4-Apr P
100002 3-Apr A
100002 2-Apr A
100002 1-Apr P
100003 6-Apr W
100003 5-Apr P
100003 4-Apr P
100003 3-Apr A
100003 2-Apr A
100003 1-Apr A
100004 6-Apr W
100004 5-Apr P
100004 4-Apr P
100004 3-Apr P
100004 2-Apr P
100004 1-Apr P
100005 6-Apr W
100005 5-Apr P
100005 4-Apr P
100005 3-Apr A
100005 2-Apr H
100005 1-Apr A

I want to create a new query which will pick only the codes and status of the employees who are consecutively absent for 3 or more days. The output should be like the table below, so that the job can pick employees based on this.

EMP_CODE ATTENDANCE_STATUS
100001 WWAAAP
100003 WPPAAA

Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>