I have a table create table date_period(dt_from date, dt_to date);
and I want to generate 1 column output with dates between every 2 dates that I have.
I wrote this:
select (dt_from - 1 + ROWNUM)
from date_period
connect by ROWNUM <= (trunc(dt_to) - trunc(dt_from) + 1)
but it doesn't work properly for some reason, it only works when there's only 1 row in the date_period
table.
What is my mistake? How do I fix this?
For example, if I have 2 rows in my table:
13-FEB-2023, 15-FEB-2023
20-JUN-2023, 22-JUN-2023
I want to return this:
13-FEB-2023
14-FEB-2023
15-FEB-2023
20-JUN-2023
21-JUN-2023
22-JUN-2023
But with the query I wrote, I get this:
13-FEB-23
14-FEB-23
15-FEB-23
23-JUN-23
I was able to achieve this using recursive common table expressions, but how do I do this with connect by?