How to perform auto-increment with dependency on column in SQL Server -


i trying figure out how auto-increment based on change in values in different column shown below

this getting right now

otherid | autoincrement --------+---------------       | 1       | 2  b       | 3 c       | 4 d       | 5 d       | 6 

this hoping for

otherid | autoincrement --------+---------------       | 1       | 1  b       | 2 c       | 3 d       | 4 d       | 4 

try using row_number()

select row_number() over(partition otherid  order  (select 1)),autoincrement mytable 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -