Skip to content

Instantly share code, notes, and snippets.

@niaher
Created July 9, 2015 11:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niaher/cccc35ae58076095784e to your computer and use it in GitHub Desktop.
Save niaher/cccc35ae58076095784e to your computer and use it in GitHub Desktop.
Update column counter per group
;with Counters as (
select Id,
row_number() over (partition by GroupingColumn order by GroupingColumn asc) as [Counter]
from RequisitionLine
)
update T
set T.[Counter] = C.[Counter]
from MyTable T inner join Counters C on T.Id = C.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment