I would like to print in one row start date and end date for continous or overlaping date ranges.
here is the data
create table orders (
po varchar2(6),
st
There is an elegant (and efficient) solution using the match_recognize
clause (which requires Oracle 12.1 or higher).
select po, startdate, enddate
from orders
match_recognize (
partition by po
order by startdate
measures first(startdate) as startdate, max(enddate) as enddate
pattern ( c* n )
define c as max(enddate) + 1 >= next(startdate)
);