I'm on oracle 10g. Looking for code samples that will caluclate days_diff between 2 dates on different rows. Below is some sample data.
Group by Field1
Row 1 = Days_diff between Row 1 e_dt and Row 2 b_dt
Row 2 = Days_diff between Row 2 e_dt and Row 3 b_dt
Row 3 = no calc because of change of Field 1 group
Row 4 = Days_diff between Row 4 e_dt and Row 5 b_dt
Row 5 = no calc because of change of Field 1 group
Row field1 b_dt e_dt days_diff
1 1000038 08-JAN-2013 10:41:00 PM 11-JAN-2013 10:57:00 PM 5
2 1000038 16-JAN-2013 07:18:00 PM 18-JAN-2013 08:29:00 PM 13
3 1000038 01-FEB-2013 07:18:00 PM 08-FEB-2013 08:29:00 PM 0
4 1002739 23-JAN-2013 11:35:00 AM 26-JAN-2013 07:56:00 PM 1
5 1002739 27-JAN-2013 06:00:00 PM 30-JAN-2013 04:26:00 PM 0
Any suggestions much appreciated.
Thank you.
Group by Field1
Row 1 = Days_diff between Row 1 e_dt and Row 2 b_dt
Row 2 = Days_diff between Row 2 e_dt and Row 3 b_dt
Row 3 = no calc because of change of Field 1 group
Row 4 = Days_diff between Row 4 e_dt and Row 5 b_dt
Row 5 = no calc because of change of Field 1 group
Row field1 b_dt e_dt days_diff
1 1000038 08-JAN-2013 10:41:00 PM 11-JAN-2013 10:57:00 PM 5
2 1000038 16-JAN-2013 07:18:00 PM 18-JAN-2013 08:29:00 PM 13
3 1000038 01-FEB-2013 07:18:00 PM 08-FEB-2013 08:29:00 PM 0
4 1002739 23-JAN-2013 11:35:00 AM 26-JAN-2013 07:56:00 PM 1
5 1002739 27-JAN-2013 06:00:00 PM 30-JAN-2013 04:26:00 PM 0
Any suggestions much appreciated.
Thank you.