Suppose I have a table Item (Id int Primary Key, Number INT) having records
Id Number
100 3
200 3
Now I am running a query
SELECT I.Id,ROW_NUMBER()OVER(ORDER BY I.Number) RN
FROM Item I
in my machine result set is
Id RN
100 1
200 2
Now my question is does this result set will be on all machine, OR in some machine it may change as
Id RN
200 1
100 2
Any help is welcome
As well as the undefined order of results mentioned by Panagiotis
The result of
ROW_NUMBERis undeterministic in the event of ties. You would need to add a tie breaker of a unique column to theORDER BYso that the two rows withNumber=3have a deterministic numbering applied.Assuming
Idis unique the following would be deterministic