• I would use a CTE together with ROW_NUMBER() OVER(PARTITION BY SensorID ORDER BY DateTime) AS row and do a self (outer?) join on it based on Sensorid and cte1.row=cte2.row-1

    If you need more details please see Wayne's post and help us help you.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]