name | class | marks | new_column## | Heading ## |
---|---|---|---|---|
jim | 1 | 50 | 1 | |
jim | 2 | 50 | 1 | |
jim | 3 | 40 | 1 | |
tom | 4 | 30 | 2 | |
tom | 3 | 70 | 2 | |
tom | 2 | 80 | 2 | |
tom | 1 | 70 | 2 | |
tom | 5 | 80 | 2 |
The name column changes every time I query but a similar name will come each time(like 5 Herry, 6 Lucy).
So I want a new_column where first similar names are assigned 1 and next similar names will be assigned 2 and so on.
1条答案
按热度按时间ljsrvy3e1#
您正在查找
dense_rank
窗口函数: