• Glad to help, Wayne 😀

    SET DATEFORMAT MDY;

    -- See how this starts off with a table and data in it?

    -- If you had provided us the data in this format,

    -- it would have made things easier for all of the

    -- volunteers on this site to help you out.

    DECLARE @TempByVolume Table (

    [DateTime] datetime,

    SensorID varchar(6),

    Temperature float,

    Volume float);

    INSERT INTO @TempByVolume

    SELECT '9/28/2010 7:34:24 PM', 'J-2933', 44.673, 590.23 UNION ALL

    SELECT '9/28/2010 7:35:29 PM', 'J-2933', 44.411, 590.02 UNION ALL

    SELECT '9/28/2010 7:36:30 PM', 'J-2933', 44.954, 590.33 UNION ALL

    SELECT '9/28/2010 7:38:33 PM', 'J-2933', 45.723, 591.04 UNION ALL

    SELECT '9/28/2010 7:40:31 PM', 'J-2933', 47.498, 591.22 UNION ALL

    SELECT '9/28/2010 7:42:34 PM', 'J-2933', 51.266, 591.41 UNION ALL

    SELECT '9/28/2010 7:44:37 PM', 'M-7341', 87.455, 780.44 UNION ALL

    SELECT '9/28/2010 7:44:38 PM', 'J-2933', 54.447, 591.61 UNION ALL

    SELECT '9/28/2010 7:46:37 PM', 'M-7341', 85.731, 780.26;

    WITH CTE AS

    (

    -- order rows by datetime, starting over for each sensor.

    SELECT *,

    RN = ROW_NUMBER() OVER (PARTITION BY SensorID ORDER BY [DateTime])

    FROM @TempByVolume

    )

    SELECT t1.SensorID, t1.[DateTime], t1.Temperature, t2.Temperature, t1.Volume, t2.Volume

    FROM CTE t1

    JOIN CTE t2

    ON t1.SensorID = t2.SensorID

    AND t2.RN = t1.RN - 1

    WHERE t1.[DateTime] between '9/28/2010 7:35:29 PM' and '9/28/2010 7:42:34 PM'

    AND t1.SensorID = 'J-2933';



    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]