Reputation: 75
I want to have an ID which is the same for all entries within a partition.
Thinking of a table with columns lie this (having a table with the three columns on the left
How can I generate the new ID on the right? I thought about row_numer() over (Partion by)... but I could not find a good way to do it.
Upvotes: 0
Views: 425
Reputation: 48197
SELECT *, RANK() OVER (ORDER BY name, attr) as new_id
FROM YourTable
Upvotes: 1