Вы можете попробовать exists
:
select t.*
from t
where exists (select 1
from t t2
where t2.transactionId = t.transactionId and
t2.enddate > t.startdate and
t2.startdate < t.enddate and
-- and not the same record
t2.startdate <> t.startdate and
t2.enddate <> t.enddate
);
Как насчет фразы, как этот?
select t.*
from t join
t t2
on t2.transactionId = t.transactionId
where t2.enddate > t.startdate and
t2.startdate < t.enddate and
t2.startdate <> t.startdate and
t2.enddate <> t.enddate
(Если у вас есть уникальный идентификатор, то этим можно заменить два последних условия.)
Возможно, вы захотите select distinct
, если это возможно.