Just add the value to the result of row_number()
:
select 3258170 - 1 + row_number() over (order by (select NULL)) as idd
The order by
clause of row_number()
is specifying what column is used for the order by. By specifying a constant there, you are simply saying “everything has the same value for ordering purposes”. It has nothing, nothing at all to do with the first value chosen.
To avoid confusion, I replaced the constant value with NULL. In SQL Server, I have observed that this assigns a sequential number without actually sorting the rows — an observed performance advantage, but not one that I’ve seen documented, so we can’t depend on it.