修改一下:
1.
create table yourtable
(字段1 varchar(20),
字段2 int)
2.
insert yourtable(字段1)
select 'aaa'
union all select 'aaa'
union all select 'bbb'
union all select 'ccc'
union all select 'aaa'
union all select 'bbb'
3.
select * from yourtable
4.
select 字段1,count(字段1) sum into #temp
from yourtable
group by 字段1
5..
update t1
set 字段2=t2.sum
from yourtable t1 join #temp t2
on t1.字段1=t2.字段1