Reputation: 469
I have a table in Snowflake with people's names and other attributes. To simplify, it looks like the table below.
How can I add a new column with assigned unique number to each person directly to the table using SQL? The ideal result is like below
Upvotes: 0
Views: 1075
Reputation: 1269483
Use dense_rank()
:
select name, dense_rank() over (order by name) as uniquenum
from t;
You can use this logic in an update
, but the exact syntax depends on the database.
Upvotes: 2