I have different records with columns Start Date and End Date. If I sort records in ascending order of start date. and want to find difference between start date of one row and end date of previous row consecutively.
e.g.
Table: Data
------------
Date1 Date2
13-DEC-2011 15-DEC-2011
18-DEC-2011 16-DEC-2011
21-DEC-2011 24-DEC-2011
one more query if I have a third column say ID and I want difference grouped by these ID's e.g
ID Date1 Date2
1 13-DEC-2011 15-DEC-2011
1 18-DEC-2011 16-DEC-2011
2 21-DEC-2011 24-DEC-2011
2 25-JAN-2012 25-FEB-2012
2 29-FEB-2012 25-MAR-2012
and I need :
ID INTERVAL FREE
1 15 DEC to 18 DEC
2 24dec to 25 jan;25 feb to 29 feb