I have an Attendance record having fields employee code, status, attendance_date.
I want to fetch those employee record who are on leave continuously for 11 days using Sql query
The condition here is if employee attendance status is continuously leave or absent or unmarked attendance(those date record which are not present in attendance doctype) for 11 days including weekend also.
The condition can be mix of all status i.e leave, absent or unmarked attendance
2
Answers
Please check the query given below.
This query finds employees who have 11 consecutive days of ‘Leave’, ‘Absent’, or ‘Unmarked’ status in their attendance records. It connects employee data with attendance data, filters for the specific statuses and date range, groups the data, and then selects only those groups where the count of records is 11.
If this query doesn’t work for you, kindly share your schema. Please identify mistake if there is any in this query.