Dette er en form for huller-og-øer. I dette tilfælde skal du bestemme, hvor øerne starter, ved at kigge efter overlapninger i begyndelsen. Lav derefter en kumulativ sum af starter og aggregering:
select max(id), min(start), max(end), max(created_at)
from (select t.*,
count(*) filter (where max_end < end) over (order by start) as grouping
from (select t.*,
max(end) over (order by start rows between unbounded preceding and 1 preceding) as max_end
from events t
) t
) t
group by grouping;