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!

Writing a SQL without using connect by and level

bunty_rsrJun 6 2020 — edited Jun 6 2020

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.

Comments
Post Details
Added on Jun 6 2020
2 comments
616 views