Reputation: 11
I need to make the Rank and Dense rank output the same as row_Number
select top(100) CVRNummer,VirksomhedNavn
,row_number() over (order by CVRNummer ) as rknr
, rank() over (order by CVRNummer) as Rankrow
/*
,DENSE_RANK() over (partition by Order by CVRNummer,VirksomhedNavn) as DrankRow
*/
from VirksomhedEllerPerson where CVRNummer is not null
order by CVRNummer,VirksomhedNavn
Upvotes: 0
Views: 68
Reputation: 11
To solve the question, you need to add Rank() OVER ( ORDER BY cvrnummer,virksomhednavn,newid()) AS rankrow
This will sort the list as requested
Upvotes: 0
Reputation: 1269503
Then just add a unique key to the order by
as the final key:
rank() over (order by CVRNummber, VirksomhedNavn)
might work. In general, you can do:
rank() over (order by CVRNummber, <primary key>)
(although any unique key will work.)
Upvotes: 1