Site icon Automotive Green

SQL: How to assign the same line number to lines with the same value?

I have a table like below in MS SQL. I reach the Row Number values with using ROW_NUMBER Partition function. But this was not the result I wanted to achieve.

RowNumber Value
1 A
2 A
3 A
1 B
2 B
1 C
1 D

I want to reach this table

RowNumber Value
1 A
1 A
1 A
2 B
2 B
3 C
4 D

How can I do it, do you have a function suggestion?

Exit mobile version