Hi I have a table "EMP_LEAVE" with some records as below
Employee | Leave_Start_Date | Leave_End_Date
1 22-09-2014 26-09-2014
1 29-09-2014 03-10-2014
1 15-12-2014 19-12-2014
1 22-12-2014 24-12-2014
2 07-01-2014 10-01-2014
2 13-01-2014 17-01-2014
2 20-01-2014 24-01-2014
3 10-02-2014 13-02-2014
3 17-02-2014 21-02-2014
I want to write a SQL query to find:
Employee who has taken leaves more than or equal to "Two Consecutive" weeks or I should say Two weeks in a row?
If Yes then whats there Leave_Start_Date and Leave_End_Date for those total leaves?
Any help or direction will be appreciated.
You can write some simple query as below.
select employee, Leave_start_date, Leave_end_date from emp_leave where datediff(Leave_start_date, Leave_end_date) >= 15
This query will give you the employees which have taken leave for more than 15 days.
Thanks, Sarat
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.