79775259

Date: 2025-09-25 20:00:21
Score: 1
Natty:
Report link

I would turn to window functions and perhaps a common table expression such as:

with cte as (select * ,

row_number() over (partition by multiplier,id) as lag_multiplier

from table)

update table set id =concat(cast(cte.id,int),cast(cte.lag_multipier)

where id in (select id from table where multiplier!=0)

from table

join cte using(id);

/*Note that I don't work with UPDATE much, and haven't tested this query. So the syntax might be off. It's also a little expensive. I'm not sure if that can be improved. Best of luck.*/

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Lee