Вы можете использовать row_number()
с возможностью обновления cte :
with cte as (
select N.*, ROW_NUMBER() OVER (PARTITION BY [userName] ORDER BY rankID) AS Seq
from tableA N
)
update c
set c.[actType] = 'X'
from cte c
where seq > 1 and
not exists (SELECT 1
FROM tableA O
WHERE O.clientCode = c.clientCode AND
O.[userName] = c.[userName] AND
O.[profile] = c.[profile] AND
O.[rankID] = c.[rankID] - 1
);
Ваш синтаксис предлагает SQL Server
. Итак, вы можете использовать.