I need to get only the rows that overlap on Start
an End
Id | Start | End |
---|---|---|
1 | 2 | 5 |
2 | 3 | 7 |
3 | 6 | 8 |
4 | 9 | 10 |
So the result will be
Id | Start | End |
---|---|---|
1 | 2 | 5 |
2 | 3 | 7 |
3 | 6 | 8 |
CodePudding user response:
You could use exists logic along with the formula for the overlapping range problem:
SELECT *
FROM yourTable t1
WHERE EXISTS (
SELECT 1
FROM yourTable t2
WHERE t2.id <> t1.id AND t2.Start <= t1.End AND t2.End >= t1.Start
);