[P]SQL code[/P]
create table #a(a varchar(50),b varchar(10))
insert into #a
select 'aaa','' union all
select 'aaa','' union all
select 'aaa','' union all
select 'aab','' union all
select 'aac','' union all
select 'aac',''
select a,
row_number()over(partition by a order by getdate()) as num
from #a