I am having a LEAVE table as following
EMPID LEAVEDT APPDT LEAVETYPE
------ ------- ------- ---------
E1 10-3-13 5-3-13 CL
E1 11-3-13 5-3-13 CL
E1 12-3-13 5-3-13 CL
E1 13-3-13 5-3-13 SL
E1 14-3-13 5-3-13 SL
E1 15-3-13 5-3-13 PL
E1 16-3-13 5-3-13 CL
E1 17-3-13 5-3-13 CL
E1 18-3-13 5-3-13 PL
E1 19-3-13 5-3-13 PL
E1 20-3-13 5-3-13 CL
Now I want to fetch the record in which i want to show how many times and for how many days employee E1 has taken each type of leave. For the above example my query result should be :---
EMPID FROM TO LEAVETYPE
----- ----- ------ ---------
E1 10-3-13 12-3-13 CL
E1 13-3-13 14-3-13 SL
E1 15-3-13 15-3-13 PL
E1 16-3-13 17-3-13 CL
E1 18-3-13 19-3-13 PL
E1 20-3-13 20-3-13 CL
please help me with suitable sql query.
Please note: empid
and leavedt
are primary keys of my table.