• The columns would be

    prevcostcenter, prevpaymentcode, previnvno, nextcostcenter, nextpaymentcode, nextinvno.

    all the columns define the next or previous row.

    I have tried the rownumber the estimated rows in the execution plan is always the total rows Iin the table. If there are 100,000 rows it take 1-2 seconds to get the data.