create table t23 (id number, start_date date, end_date date)
Table created.
insert into t23 values (1, to_date('01/01/2017', 'DD/MM/YYYY'), to_date('01/08/2017', 'DD/MM/YYYY') )
1 row(s) inserted.
insert into t23 values (2, to_date('01/04/2017', 'DD/MM/YYYY'), to_date('01/07/2017', 'DD/MM/YYYY') )
1 row(s) inserted.
select id,
add_months(start_date, level-1 ) as which_month
from t23
connect by level <= months_between(end_date , start_date)+1
and id = prior id
and prior sys_guid() is not null
order by 1, 2
| ID | WHICH_MONTH | 1 | 01-JAN-17 | 1 | 01-FEB-17 | 1 | 01-MAR-17 | 1 | 01-APR-17 | 1 | 01-MAY-17 | 1 | 01-JUN-17 | 1 | 01-JUL-17 | 1 | 01-AUG-17 | 2 | 01-APR-17 | 2 | 01-MAY-17 | 2 | 01-JUN-17 | 2 | 01-JUL-17 |
|---|