Compare rows in tables

  • Hi,

    I need to compare concecutive records in a single table and find the difference of 1 column .

    Iam grouping with rownumber ,but how do I compare the row 2 with row 1

    row3 with row2 and get the difference.

    Thanks for your help.

    Demin

  • Hi,

    if you have the row number for the table already you could join this table in on itself as below allow you to join one row to the next

    SELECTtable1.column1,

    table2.column2

    FROM Sampletable as table 1

    LEFT OUTER JOIN Sampletable as table2

    ON table1.rownumber+1 = table2.rownumber

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply