Hi,If the rows are uniquely identified by an identity (or other sequential "key") meaning that the version is just another data column, and by "next version" you mean the version data from the row with the next sequential id then:Set NoCount ONCreate table MyTable (Id int identity, Version int)Insert Into MyTable (Version) values (1)Insert Into MyTable (Version) values (5)Insert Into MyTable (Version) values (3)Insert Into MyTable (Version) values (7)Insert Into MyTable (Version) values (5)Select A.Id, A.Version ,(Select Top 1 B.Version From MyTable B Where B.Id > A.Id order By B.Id) as Next_Version From MyTable ADrop table MyTable
Returns:Id Version Next_Version ----------- ----------- ------------ 1 1 52 5 33 3 74 7 55 5 NULL
I hope I interpreted your question correctly, and I hope this helps.