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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -