We are migrating code from oracle db to Redshift. We came across the queries using connect by and level.
Redshift cannot use connect by and level keywords. Below is the query.
select add_months (last_day(dt.start_dt), level) as start_dt
from
(select sysdate-30 as start_dt, sysdate as end_dt from dual) dt
connect by add_months (trunc(dt.start_dt), level)- 1 <= dt.end_dt
order by 1 desc
Thank you in advance.