座席在上一个仍在进行时开始呼叫

Agent start a call when the previous is still in progress

我有一个电话 table

CALL_ID | OPERATOR_ID |       CALL_START      |        CALL_END       | NOTES | TYPE
========+=============+=======================+=======================+=======+======
    101 |    3000     | '2020-12-12 08:00:00' | '2020-12-12 08:10:00' |  ...  | ...
    102 |    3000     | '2020-12-12 08:08:00' | '2020-12-12 08:20:00' |  ...  | ...

CALL_ID 102 在 CALL_ID 101 结束之前开始(对于相同的 operator_ID)。

我需要找到 CALL_END > CALL_START 的调用(在同一操作员的下一行),但我被卡住了。

通过 OPERATOR_ID 加入针对自身的 CALLS table,寻找在任何“左手”通话记录的 CALL_START 之间具有 CALL_START 的“右手”通话记录和 CALL_END:

SELECT c.operator_id,
       c.call_id,
       c.call_start,
       c.call_end,
       other.call_id,
       other.call_start
  FROM calls c
 INNER JOIN
       calls other
    ON c.operator_id = other.operator_id
 WHERE c.call_id != other.call_id
       AND
       other.call_start BETWEEN c.call_start AND c.call_end