Update a column with sequence numbers without using ROW_NUMBER() in SQL Server -


i have table , have difficulty updating it

code    descd   slnum ---------------------  10              0 10       b        0 12       c        0 12       d        0 11       e        0 12       f        0 

i have update table without using row_number() using if else loops how can that?

code    descd   slnum ---------------------- 10              1 10       b        2 12       c        1 12       d        2 11       e        1 12       f        3 

for sql 2012+

    ;with rownum(code, descd, slnum) (     select 10, 'a', 0     union select 10, 'b', 0     union select 12, 'c', 0     union select 12, 'd', 0     union select 11, 'e', 0     union select 12, 'f', 0     ) select code, descd, count(*) on (partition code order code              rows unbounded preceding) rownum o order descd 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -