Hi if u are working in sql2000 then use thisdeclare @t table (A varchar(32))insert into @t select 'John' union all select 'John' union all select 'John' union all select 'Mich' union all select 'Mich' union all select 'Terry' union all select 'Terry' union all select'Terry' union all select'Terry' select identity(int,1,1)as rid, * into #temp from @tselect a,(select count(a) from #temp where rid <= t.rid and a= t.a)as cntfrom #temp t