Relative Content

Tag Archive for sqloracleconnect-by

How to deal with a NULL in Connect By Level without the query going on forever?

I have a leases table, with start and end date of each lease. Some leases don’t have an end date, and the field is NULL.
I want to generate a list of the payment dates/amounts over the duration of the lease. For the leases with an end date, I’m using CONNECT BY LEVEL <= TRUNC(MONTHS_BETWEEN(pl.END_DATE, pl.START_DATE)+1,0).