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 -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -