Getting max needed Staff

  • Hey,

    i know that this is maybe not a typicaly question for this forum, but maybe someone can help me out to find a solution for my problem:

    Let's say we have following table:

    ID requiredStaff(int) start(dateTime) end (dateTime)
    1 1 2018-05-18 10:00:00 2018-05-18 12:00:00
    2 2 2018-05-18 11:30:00 2018-05-18 15:30:00
    3 4 2018-05-18 15:00:00 2018-05-18 16:00:00

    Now i want to know, how many Employee are needed maximum concurrently. In this case, the result has to be 6, because, ID2& ID3are overlapping and the sum of 2 and 4 is 6.

    ID1 and ID2are also overlapping, but the sum of 1 and 2 is small then the other result, you know?

    I really have no idea how to design this query... Can sombody help me with that?