Mysql horizontalizing grouping
SELECT t1.sessionId, t1.dt StartTime, TIMEDIFF(t2.dt, t1.dt) duration
FROM src t1
JOIN src t2 ON t1.event = 'start'
           AND t2.event = 'end'
           AND t1.sessionId = t2.sessionId
           AND t1.dt &lt; t2.dt
           AND NOT EXISTS ( SELECT NULL
                            FROM src t3
                            WHERE t3.sessionId = t1.sessionId
                              AND t1.dt &lt; t3.dt
                              AND t3.dt &lt; t2.dt );


fiddle