declare @t table(id int, name varchar(10))
insert into @t select 1,'a'
union all select 2,'a'
union all select 3,'b'
union all select 4,'b'
union all select 5,'b'
select *,name=name+'-'+ltrim((select sum(1) from @t where name=tb.name and id<=tb.id)) from @t tb
/*
id name name
----------- ---------- -----------------------
1 a a-1
2 a a-2
3 b b-1
4 b b-2
5 b b-3