MySQL get previous row with inner join
Use that query as a 'derived table' to finish the task:

SELECT ...
    FROM ( ... your query ... ) AS x
    JOIN calendar AS prev_row  ON prev_row.calendar_id = x.previous
    ...


(If you are using MySQL 8.0, there is a "windowing" way to get the previous id.)