Posted by markc600 on 10/09/06 12:22
Try this
SELECT s1.Start,
MIN(t1.Stop) AS Stop
FROM Intervals s1
INNER JOIN Intervals t1 ON s1.Start <= t1.Stop
AND NOT EXISTS(SELECT * FROM Intervals t2
WHERE t1.Stop BETWEEN t2.Start AND t2.Stop
AND t2.Stop > t1.Stop)
WHERE NOT EXISTS(SELECT * FROM Intervals s2
WHERE s1.Start BETWEEN s2.Start AND s2.Stop
AND s2.Start < s1.Start)
GROUP BY s1.Start
Navigation:
[Reply to this message]
|