create table tb (id int ,姓名 varchar(20) ,部门 varchar(20),counts int)
insert into tb
select 1,'aa','生产',1
union all
select 2,'aa','生产',1
union all
select 3,'bb','生产',1
union all
select 4,'bb','生产',1
union all
select 5,'cc','生产',1
update tb
set counts=AA.counts
from tb,(select 姓名 ,count(*) as counts from tb group by 姓名) AA
where tb.姓名=AA.姓名