• YUK!

    interesting challenge. If I were to do it in the code I would be looking at either RANK() OVER() in a CTE to sequence the entries and then left join the CTE to itself based on CTE2.StartDate <= CTE1.EndDate. When you have data in the right hand table then there is an overlap.  

    Alternatively you could do it with a CURSOR, order the entries by start datetime and track the largest end datetime,  If the current records start datetime < max end datetime then it is part of the same group. Assign a group number and then see if the current records end datetime > max end datetime then update max end datetime with current record end (this caters for E1 = 09:00-17:00, E2 = 11-:00-13:00, E3 = 12:00-18:00

    HOWEVER
    you should be able to solve your layout problem using either CSS flexbox to get the events to float right. Also have a look to see whether CSS grids might help you out.