對於完全相同的開始時間和結束時間collissions
with records as(
select starttime, endtime from table group by starttime, endtime where count(starttime)>1
)
select recordno from table t
inner join records r on t.starttime=r.starttime and t.endtime=r.endtime
,但我想你可能要重疊碰撞太
select t1.recordno
from table t1
inner join table t2
on (t1.starttime between t2.starttime and t2.endtime)
or
(t1.endtime between t2.starttime and t2.endtime)
這是一個有點危險,但因爲它會在表中加入的每個記錄表中的每條記錄。如果表格中有10行,它將創建一個100行集合,然後將其縮小爲結果。對於100行,它會在縮小結果之前創建10000行。
行^ 2
根據您最後的評論也許你會想這樣做基於描述和不同的布爾和確切時間第二種方法在這種情況下,找回了重複的事務
select t1.recordno
from table t1
inner join table t2
on t1.starttime=t2.starttime
and t1.endtime=t2.endtime
and t1.description=t2.description
and t1.Bool1 != t2.Bool1
and t1.Bool2 != t2.Bool2
爲什麼如果它是碰撞,表格存儲?通常你會在查詢中計算出來,不要存儲它。我也希望'Bool1'和'Bool2'不是真名。如果一個事件的開始時間小於另一個事件的結束時間,那麼 –
會不會有調度衝突? –
其目的是查找不同記錄但僅在這兩個布爾字段上具有相同描述的記錄。這些字段的真實姓名是ARJ和ANK。所以邏輯是,如果我們有一個具有相同描述符和兩個不同數字的行爲,一個具有ARJ,另一個具有ANK,則將這兩個記錄作爲碰撞返回。 – bbcompent1