Skip to content

Instantly share code, notes, and snippets.

@codingawayy
Created July 9, 2015 11:19
Show Gist options
  • Save codingawayy/cccc35ae58076095784e to your computer and use it in GitHub Desktop.
Save codingawayy/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