Postgresql Recursion Query
Thanks for the fiddle, I extended it a bit: fiddle

select distinct effective_from, archived, cal
from (
    select s1.effective_from
         , s1.archived
         , s1.cal
         , row_number() over (partition by s2.effective_from 
                              order by s1.archived desc) as rn
    from stack_question s1 
    join stack_question s2 
        on s1.effective_from &lt; s2.archived
) as t
where rn = 1
;


I'm in a bit of a hurry, so I don't time to investigate further, but it should give you a start. The idea is to enumerate the rows from s2 to get archive