From: Plamen Ratchev on
The query that I posted works fine for consecutive entries, but you may look for ways to simplify it.

--
Plamen Ratchev
http://www.SQLStudio.com