A sandwich absent is when an employee is absent on the day before and after of weekly_off day. For example weekly_off is on Sun and an employee is absent on both Fri and Sat
COUNT(CASE WHEN
(a.status = 'Absent') AND
(DATE_ADD(a.attendance_date, INTERVAL 1 DAY) IN (select h.holiday_date from `tabHoliday` as h where h.weekly_off = 1)) AND
(DATE_ADD(a.attendance_date, INTERVAL 2 DAY) IN (select a.attendance_date from `tabAttendance` a where a.status='Absent')) THEN 1 END) AS sandwich_leave
This is a limited case based on your example. This checks for a day the employee was absent and checks the next 2 days for
If the subsequent day was wekly off
If the day after the weekly off , the employee was absent
You can modify the query to include holidays other than weekly off. But if you want to query case where there are multiple weekly offs, then that would be different.
Through some logic changes I was able to make my case where an employee was absent before and after the weekly_off, here you can see the dates when the employee was absent: