By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tab
AS
SELECT 1 AS col1 , 1 AS col2 , 2 AS col3
UNION ALL SELECT 1 , 1, 2
UNION ALL SELECT 1, 2 , 2
SELECT *,CONCAT('newid', DENSE_RANK() OVER(ORDER BY col1,col2,col3)) AS newcol
FROM tab
col1 | col2 | col3 | newcol |
---|---|---|---|
1 | 1 | 2 | newid1 |
1 | 1 | 2 | newid1 |
1 | 2 | 2 | newid2 |