Many of you might aware of sandwich leave. But how to implement at database level its bit difficult for me. I have scenerio where if employees took 2 LEAVE i.e. before and after of their WEEK-OFF then all the 3 days should marked as LEAVE. Below is the basic requirement I am sharing.
HERE IS REQUIREMENT OF SANDWICH LEAVE
Here is some sample data. It may eventually occur to me to supplement this with a corresponding desired result.
CREATE TABLE IF NOT EXISTS `atnsystem` (
`Emp_id` int unsigned NULL,
`attendance_date` date NULL,
`in_datetime` datetime NULL,
`out_datetime` datetime NULL,
`remark` varchar(100) NULL
) DEFAULT CHARSET=utf8;
INSERT INTO `atnsystem` (`Emp_id`, `attendance_date`, `remark`) VALUES
('66', '2020-02-17', 'LEAVE'),
('66', '2020-02-16', 'WEEK-OFF'),
('66', '2020-02-15', 'LEAVE');
This is the SQL_FIDDLE link table created in fiddler
I want if remark is like LEAVE , WEEK-OFF and LEAVE again then that WEEK-OFF should get CONVERTED to LEAVE as well.
It doesn't matter what get inserted but while using SELECT query if it found YESTERDAY as LEAVE and TODAY as WEEK-OFF and then again next day as LEAVE then the WEEK-OFF day should get considered as LEAVE as well. I hope I made my query clear and any help will be highly appreciated.