My question is very similar to the one in this thread. However, I just have 1 table with fields ID Eff_Date End_Date. It actually is a bigger table with more fields, but I just listed those that are relevant here.
What is a simple and efficient way to find rows with time-interval overlaps in SQL?
I need to write a SQL statement to fetch records that have the same ID with overlapping effective date periods. A valid record usually has end_date as '99991231'.
select ID, DEFF, DEND
from table1
where ID in (
select ID
from table1
where DEND = 99991231
group by ID
having COUNT(*) >1)
and DEND = 99991231
order by 1,2
Any thoughts will help!