Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL to get continuous records

Raj0046May 25 2025

Hi Gurus & @mathguy ,

Please find the table structure and insert statements:

create table tv_temp1(person_id number,date_start date,date_end date,ABSENCE_ATTENDANCE_TYPE_ID number);
insert into tv_temp1 values(1,to_date('15-Jan-2025'),to_date('17-Jan-2025'),1);
insert into tv_temp1 values(2,to_date('20-Jan-2025'),to_date('22-Jan-2025'),1);
insert into tv_temp1 values(1,to_date('18-Jan-2025'),to_date('20-Jan-2025'),1);
insert into tv_temp1 values(1,to_date('22-Jan-2025'),to_date('28-Jan-2025'),1);
insert into tv_temp1 values(1,to_date('10-Feb-2025'),to_date('12-Feb-2025'),1);

insert into tv_temp1 values(2,to_date('27-Jan-2025'),to_date('02-Feb-2025'),1);

insert into tv_temp1 values(2,to_date('03-Feb-2025'),to_date('10-Feb-2025'),1);

My requirement is to get start_date & end_date for continuous absence records, eg for person_id 1 (records highlighted in bold), there is continuous absence records, 15-Jan to 17-Jan, 18-Jan to 20-Jan, where as for other records for person_id 1, there are no continuous absence records, so I need output as below:

Person_id Date_start Date_End

1 15-Jan-25 20-Jan-25

2 27-Jan-25 10-Feb-25

Regards

Raj

This post has been answered by Frank Kulash on May 25 2025
Jump to Answer
Comments
Post Details
Added on May 25 2025
4 comments
348 views